libxml2 XML_PARSE_HUGE option for xmlParseMemory

六眼飞鱼酱① 提交于 2019-12-24 12:33:53

问题


C++ on Centos 6.4, libxml2.x86_64 2.7.6-12.el6_4.1:

I'm trying to fix an old C++ program that occasionally gets XML parser errors on large xml files, seems to need the XML_PARSE_HUGE option set. But I can't see any place to set it! The code that's failing is using the xmlParseMemory function which only has 2 parameters - the char array to parse and its size.

Is there some way to set the XML_PARSE_HUGE option globally?


回答1:


You have to switch to xmlReadMemory which has an options parameter. Simply convert calls like

xmlParseMemory(buffer, size);

to

xmlReadMemory(buffer, size, NULL, NULL, XML_PARSE_HUGE);

(I think xmlParseMemory predates the parser options and is only retained for backward compatibility. Also see this question.)



来源:https://stackoverflow.com/questions/24531634/libxml2-xml-parse-huge-option-for-xmlparsememory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!