php - XMLReader encoding error -
I have PHP scripts trying to parse a huge XML file. To do this, I am using the XMLReader library. During parsing, I have this encoding error:
The input is not the appropriate UTF-8, point to the encoding! Bytes: 0xA0 0x32 0x36 0x30
I would like to know if they are a way to leave bad character archives.
Thank you! First, make sure that your XML file is actually UTF-8 encoded. If the encodings do not specify the second parameter.
If the encoding error is due to an actual defective byte sequence in a UTF-8 document and if you are using PHP> 5.2.0 then you pass LIBXML_NOERROR and / Or as a bitmask for the third parameter of LIBXML_NOWARNING (depending on error level):
$ xml = new XMLReader (); $ Xml- & gt; Open ('myxml.xml', tap, LIBXML_NOERROR | LIBXML_NOWARNING); If you are using PHP> 5.1.0 you can tweak error-handling.
// enabling user error handling libxml_use_internal_errors (true); / * ... Processing your XML ... * / $ errors = libxml_get_errors (); Foreign currency ($ errors as dollar error) {// handy errors are here} libxml_clear_errors (); I do not know that the last two tasks-around actually allow XMLReader to continue reading in the case of an error or if they only error Suppresses the output.
libXML (1) but ext / libxml does not display this static in the form of PHP constants, possibly by It is possible to assign an integer value to 1 in the $ option parameter.
$ xml = new XMLReader (); $ Xml- & gt; Open ('myxml.xml', tap, LIBXML_NOERROR | LIBXML_NOWARNING | 1);
Comments
Post a Comment