X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FXML.php;h=963161fbffb2add74f70d8874380a795800e6a1e;hb=8dc0ab9bb3379fec0be442160db1ae29ef8cea9d;hp=4eed3a85f84eb511b0859521d75be1a34a99a760;hpb=f521689ced8119ccc0479ff47d890f5a4bee87ba;p=friendica.git diff --git a/src/Util/XML.php b/src/Util/XML.php index 4eed3a85f8..963161fbff 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -1,6 +1,6 @@ code . " at " . $err->line . ":" . $err->column . " : " . $err->message, Logger::DATA); + Logger::debug('libxml: parse: ' . $err->code . " at " . $err->line . ":" . $err->column . " : " . $err->message); } libxml_clear_errors(); return; @@ -475,7 +475,7 @@ class XML public static function getFirstAttributes(DOMXPath $xpath, $element, $context = null) { - $result = $xpath->query($element, $context); + $result = @$xpath->query($element, $context); if (!is_object($result)) { return false; } @@ -488,6 +488,21 @@ class XML return $first_item->attributes; } + public static function getFirstValue($xpath, $search, $context) + { + $result = @$xpath->query($search, $context); + if (!is_object($result)) { + return ''; + } + + $first_item = $result->item(0); + if (!is_object($first_item)) { + return ''; + } + + return $first_item->nodeValue; + } + /** * escape text ($str) for XML transport *