10
As I understand the answers of this question from the OS, the XMLReader::isValid()
checks "only the current node, not the whole document". What does that mean?
In case I want to validate if xml is valid before doing:
$meuXml = simplexml_load_string($meuXml);
Because sometimes I think the xml comes poorly formed, so I get a type error:
stderr: PHP message: PHP Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<
So basically the question is : What is the best way to verify a document .xml
is valid using PHP? But I would also like to know what "checking only the current node, not the entire document".
Anderson, in this case already evaluates the whole XML or just one of the nodes... btw I haven’t quite understood the question of the nodes, if you can give a brief explanation...
– gustavox
@gustavox XML in
$meuXml
whole. The return oflibxml_get_errors
will be a array with all the mistakes.– Woss