X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FXML.php;h=4eed3a85f84eb511b0859521d75be1a34a99a760;hb=e52e505a481ed6f7e3766725d709b5f0653b036b;hp=9aba38910d6a7a0020e743d8f95ba30ec24690b2;hpb=0e05ff68686270d87447c570e28543a5bcc7e755;p=friendica.git diff --git a/src/Util/XML.php b/src/Util/XML.php index 9aba38910d..4eed3a85f8 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -433,18 +433,26 @@ class XML } } - public static function parseString($s, $strict = true) + /** + * Parse XML string + * + * @param string $s + * @param boolean $suppress_log + * @return Object + */ + public static function parseString(string $s, bool $suppress_log = false) { - // the "strict" parameter is deactivated libxml_use_internal_errors(true); $x = @simplexml_load_string($s); if (!$x) { - 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]); + 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;