X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FXML.php;h=7b4539ba8cdd10a066ba44c52730d432ddb90168;hb=aad7bac6866cade9c07bb152e658eb23c4e37426;hp=9aba38910d6a7a0020e743d8f95ba30ec24690b2;hpb=2c56d2f3360c08e312e5c167261af8e5d4b87af4;p=friendica.git diff --git a/src/Util/XML.php b/src/Util/XML.php index 9aba38910d..7b4539ba8c 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -1,6 +1,6 @@ System::callstack()]); - foreach (libxml_get_errors() as $err) { - Logger::info('libxml error', ['code' => $err->code, 'position' => $err->line . ":" . $err->column, 'message' => $err->message]); + if (!$suppress_log) { + Logger::error('Error(s) while parsing XML string.', ['callstack' => System::callstack()]); + foreach (libxml_get_errors() as $err) { + Logger::info('libxml error', ['code' => $err->code, 'position' => $err->line . ":" . $err->column, 'message' => $err->message]); + } + Logger::debug('Erroring XML string', ['xml' => $s]); } - Logger::debug('Erroring XML string', ['xml' => $s]); libxml_clear_errors(); } return $x; @@ -480,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 *