note 37069 deleted from function.domxml-open-mem by sobak
| From: | sobak@php.net | Date: | Tue, 22 Nov 2016 03:41:28 +0000 |
| Subject: | note 37069 deleted from function.domxml-open-mem by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207407@lists.php.net to get a copy of this message | ||
Note Submitter: chris at schaake dot nu
----
Finally figured out the error handling. The sample below will give a nice error message. Should also
work for domxml_open_file.
<?
# Small sample xml file with 2 errors
# 1. root tag not closed
# 2. Missing ; in &
$xml = "<root>&";
$xmldoc = @domxml_open_mem($xml,DOMXML_LOAD_PARSING,$error);
echo "<pre>"; # Just for nice layout
foreach ($error as $errorline) { # Loop through all errors
echo $errorline['errormessage'];
echo " Node : " . $errorline['nodename'] . "\n";
echo " Line : " . $errorline['line'] . "\n";
echo " Column : " . $errorline['col'] . "\n\n";
}
?>