Question

I use libxml2 to parse big xml file.I refer to the example.when xml node value is large(more than 4M),xmlTextReaderRead alway return -1.I am sure xml file is right. Is it libxml2's bug?What should I do now?

Was it helpful?

Solution

If you want to parse multi-megabyte text nodes, you have to use the XML_PARSE_HUGE option. So instead of xmlNewTextReaderFilename, use the xmlReaderForFile constructor which allows to pass parser options:

reader = xmlReaderForFile(filename, NULL, XML_PARSE_HUGE);

This option is disabled by default to prevent DoS attacks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top