Hello
I've seen this question posted a few times without an answer, but hopefully someone may have cracked it now. I am parsing a large number of XML documents stored in a MySQL database with SAX but when it reaches the end of the document it dies with XML error: junk after document element at line 241, that line being the final line of the XML. The XML is valid and is parsed without any problems if loaded as a file, but when pulled from a MySQL field that stores the XML as a TEXT field and passed as a variable the error appears. I am using the standard PHP technique of
while ($data) {
if (!xml_parse($this->xmlParser, $data)) {die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($this->xmlParser)),
xml_get_current_line_number($this->xmlParser)));
}
That is simply the technique of reading in a file transposed to reading in a variable. Does anybody know of a solution using this code or is there any other way, perhaps using the org.xml.sax.InputSource class.
Any help is greatly appreciated.
Thanks
David