import com.ximpleware.*; public class queryXML{ public static void main(String[] s) throws VTDException{ VTDGen vg = new VTDGen(); vg.selectLcDepth(5); if (!vg.parseFile("d:\\xml\\test11.xml", false)) return; VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.declareNameSpace("ss","urn:schemas-microsoft-com:office:spreadsheet"); ap.selectXPath("/Workbook/ExcelWorkbook/Worksheet/Table/Cell/ss:data/font/text()"); int i=0; while((i=ap.evalXPath())!=-1){ System.out.println(" data content ==>"+vn.toString(i); } } }
import com.ximpleware.*; public class queryAttr { public static void main(String[] s) throws VTDException{ VTDGen vg = new VTDGen(); vg.selectLcDepth(5);// improve XPath performance for deep document if (!vg.parseFile("input.xml", false)) return; VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.selectXPath("/BatchItemFullInfoAnswer/Result/Item/ConfiguredItems/OtapiConfiguredItem/Configurators/ValuedConfigurator"); int i=0,j=0; while((i=ap.evalXPath())!=-1){ j= vn.getAttrVal("pid"); if (j!=-1) System.out.println(" attr value for pid is ==>"+vn.toString(j)); j= vn.getAttrVal("vid"); if (j!=-1) System.out.println(" attr value for vid is ==>"+vn.toString(j)); } } }
import com.ximpleware.*; public class queryAttr { public static void main(String[] s) throws VTDException{ VTDGen vg = new VTDGen(); vg.selectLcDepth(5);// improve XPath performance for deep document if (!vg.parseFile("input.xml", false)) return; VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.selectXPath("/BatchItemFullInfoAnswer/Result/Item/ConfiguredItems/OtapiConfiguredItem/Configurators/ValuedConfigurator/@pid"); AutoPilot ap2 = new AutoPilot(vn); ap2.selectXPath("../@vid"); int i=0,j=0; while((i=ap.evalXPath())!=-1){ System.out.println(" attr value for pid is ==>"+vn.toString(i+1)); // notice this is i+1, not i cuz i is the vtd record index for pid vn.push();// maintain consistency of autoPilot with push/pop combo if ((j=ap2.evalXPath())!=-1) System.out.println(" attr value for vid is ==>"+vn.toString(j+1)); // notice this is j+1, not j cuz j is the vtd record index for vid vn.pop(); } } }
public static void main(String[] s) throws VTDException, Exception{ VTDGen vg = new VTDGen(); vg.selectLcDepth(5);// soap has deep nesting so set to 5 to speed up navigation if (!vg.parseFile("d:\\xml\\soap2.xml", true)) return;
public static void main(String[] s) throws VTDException{ VTDGen vg = new VTDGen(); vg.selectLcDepth(5);// improve XPath performance for deep document if (!vg.parseFile("input.xml", false)) return;
vtdGen.selectLcDepth(5); vtdGen.parseFile("c:\\xml\\agata.xml",false); AutoPilot ap = new AutoPilot(),ap1=new AutoPilot(),