}
}
+ $element = null;
foreach ($array as $key => $value) {
if (!isset($element) && isset($xml)) {
$element = $xml;
return(null);
}
+ $xml_element_copy = '';
if (!is_string($xml_element)
&& !is_array($xml_element)
&& (get_class($xml_element) == 'SimpleXMLElement')
) {
- $xml_element_copy = $xml_element;
- $xml_element = get_object_vars($xml_element);
+ $xml_element_copy = $xml_element;
+ $xml_element = get_object_vars($xml_element);
}
if (is_array($xml_element)) {
}
return $x;
}
+
+ public static function getFirstNodeValue($xpath, $element, $context = null)
+ {
+ $result = $xpath->evaluate($element, $context);
+ if (!is_object($result)) {
+ return '';
+ }
+
+ $first_item = $result->item(0);
+ if (!is_object($first_item)) {
+ return '';
+ }
+
+ return $first_item->nodeValue;
+ }
+
+ public static function getFirstAttributes($xpath, $element, $context = null)
+ {
+ $result = $xpath->query($element, $context);
+ if (!is_object($result)) {
+ return false;
+ }
+
+ $first_item = $result->item(0);
+ if (!is_object($first_item)) {
+ return false;
+ }
+
+ return $first_item->attributes;
+ }
}