我正在使用 VTD-XML 来合并大于 800MB 的 xml 文件 文件大小(很有可能达到2GB)。 我已经阅读了可以支持 2GB 的文档(如果命名空间感知是) 设置为假。 话虽如此,我如何正确使用 selecXPath() evalXPath() 和 getAttrVal() 等..? 因为我收到命名空间错误,但如果我可以正常运行 切换到 namespace 感知 true。
VTDNav gmlNav = null;
//if(! gen.parseFile(gmlFile, true)) return;
if(! gen.parseFile(gmlFile, false)) return;
gmlNav = gen.getNav();
AutoPilot gmlAutoPilot = new AutoPilot(gmlNav);
//gmlAutoPilot.declareXPathNameSpace("xlink","http://www.w3.org/1999/xlink");
//gmlAutoPilot.declareXPathNameSpace("gml","http://www.opengis.net/gml/3.2");
//sourceAutoPilot.selectXPath("//*[gml:id='123' or gml:id='456']");
sourceAutoPilot.selectXPath("//*[id='123' or id='456']");
while (sourceAutoPilot.evalXPath() != -1) {
//String gmlId = sourceNav.toString(sourceNav.getAttrVal("gml:id"));
String gmlId = sourceNav.toString(sourceNav.getAttrVal("id"));
}
注意:注释的代码是命名空间感知的。
感谢任何指导。
最佳答案
您将需要使用扩展的 VTD-XML,它在命名空间方面没有标准 vtd-xml 的限制。在标准vtd-xml中,如果启用命名空间感知,则最大文档大小为1GB。
关于Java:VTD-XML 2.10:如何:在不知道 namespace 的情况下获取属性 val?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6337954/