xmlParseMemory的libxml2 XML_PARSE_HUGE选项 [英] libxml2 XML_PARSE_HUGE option for xmlParseMemory
问题描述
在Centos 6.4上的C ++,libxml2.x86_64 2.7.6-12.el6_4.1:
C++ on Centos 6.4, libxml2.x86_64 2.7.6-12.el6_4.1:
我正在尝试修复一个旧的C ++程序,该程序偶尔会在大型xml文件上出现XML解析器错误,似乎需要设置XML_PARSE_HUGE选项.但是我看不到任何设置它的地方!失败的代码正在使用xmlParseMemory函数,该函数仅具有2个参数-要解析的char数组及其大小.
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.
是否可以通过某种方式全局设置XML_PARSE_HUGE选项?
Is there some way to set the XML_PARSE_HUGE option globally?
推荐答案
You have to switch to xmlReadMemory
which has an options
parameter. Simply convert calls like
xmlParseMemory(buffer, size);
到
xmlReadMemory(buffer, size, NULL, NULL, XML_PARSE_HUGE);
(我认为xmlParseMemory
在解析器选项之前,并且仅保留用于向后兼容.另请参见这个问题.)
(I think xmlParseMemory
predates the parser options and is only retained for backward compatibility. Also see this question.)
这篇关于xmlParseMemory的libxml2 XML_PARSE_HUGE选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!