简体   繁体   中英

How to solve 'returned null' when parsing a huge XML page with C

I'm trying to parse a huge XML clob data from oracle DB in Redhat linux 5.5, 64bit, using libxml2-2.7.6

But when I tried to parse the XML more than 400KB(409600 bytes), the xml parser function, 'xmlParseMemory' returned null pointer.

(Succeeded to load from XML clob data to string in C, checked the string 'sData' is filled with the data correctly.)

xmlDocPtr xDoc;
...
xDoc = xmlParseMemory(sData, strlen(sData));
if(xDoc == NULL)    return -1;
...

Parser does work when the size of XML is less than 400KB. But only when more then 400KB, paser returns null pointer despite correct string data, 'sData'.

And I've already tried xmlReadDoc, xmlReadMemory with using xmlMemSetup before xmlInitParser.

How can I solve this situation with using xml parser functions?

If everything works for XML with less than 400KB, I believe the problem is because of your sData buffer. You should check if the buffer has enough space for large file (more than 400kb):

  • How much memory you allocated for sData ?
  • Does the strlen(sData) valid?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM