为了在巨大的 xml 文件中执行 XPATH 查询,我阅读了许多喜欢 VTD-XML 的文章,所以我复制了这些文章中的代码:
import com.ximpleware.extended.*;
public class MainVTD {
public static void main(String[] s) throws Exception{
VTDGenHuge vg = new VTDGenHuge();
if (vg.parseFile("./resource/init/dblp_3.xml",true,VTDGenHuge.MEM_MAPPED)){
VTDNavHuge vnh = vg.getNav();
AutoPilotHuge aph = new AutoPilotHuge(vnh);
aph.selectXPath("/*/*[not(name() = name(preceding-sibling::*[1]))]");
int i ;
while ((i=aph.evalXPath())!=-1){
System.out.println(" element name is "+vnh.toString(i));
}
}else System.out.println("Doc not mapped");
}
}
但是当我在没有结果的情况下运行它时,这意味着它没有映射到内存中的 XML 文件......我的问题是如何强制在 VTD-XML 中映射 xml 文件?