Re: [xml] XML validation




Yan Seiner wrote:
Daniel Veillard wrote:
Hum, PHP uses libxml2 at least starting from 5.0. You should be able to capture the parsing error messages, check the docs, I would
be really surprized if it wasn't there.

Daniel

Well, I found this:

<http://svncommunity.digium.com/view/asterisk-docs/scripts/xml-check.php?rev=1&view=markup>

which can be adapted easily enough. The key is the passthru function which I didn't even know existed....
for early versions of PHP 5 errors from libxml2 are emitted as PHP Warnings/Notices so you need to implement an error handler if you want to capture and handle them. As of 5.1.0+, trappable structured errors were implemented. See: http://www.php.net/manual/en/function.libxml-use-internal-errors.php This type of error handling can be used with any of the XML based extensions, not just DOM.

Rob



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]