xmlParseMemory的libxml2 XML_PARSE_HUGE选项 [英] libxml2 XML_PARSE_HUGE option for xmlParseMemory

查看:305
本文介绍了xmlParseMemory的libxml2 XML_PARSE_HUGE选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆