VTDGen vg = new VTDGen(); if (vg.parseFile("c://xml//alex.txt", true)){ VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.selectXPath("//L/D"); int i=-1; while((i=ap.evalXPath())!=-1){ long l = vn.getContentFragment(); System.out.println(" -==> "+ vn.toString((int )l, (int)(l>>32))); } }
/** * This method loads the VTD+XML from an input stream * @return VTDNav * @param is * @throws IOException * @throws IndexReadException * */ public VTDNav loadIndex(InputStream is) throws IOException,IndexReadException{ IndexHandler.readIndex(is, this); return getNav(); } /**
/** * This method loads the VTD+XML from a byte array * @return VTDNav * @param ba * @throws IOException * @throws IndexReadException * */ public VTDNav loadIndex(byte[] ba)throws IOException,IndexReadException{ IndexHandler.readIndex(ba,this); return getNav(); } /**
/** * This method loads the VTD+XML from an input stream * @return VTDNav * @param is * @throws IOException * @throws IndexReadException * */ public VTDNav loadIndex(InputStream is) throws IOException,IndexReadException{ IndexHandler.readIndex(is, this); return getNav(); } /**
/** * This method loads the VTD+XML from a byte array * @return VTDNav * @param ba * @throws IOException * @throws IndexReadException * */ public VTDNav loadIndex(byte[] ba)throws IOException,IndexReadException{ IndexHandler.readIndex(ba,this); return getNav(); } /**
/** * This method loads the VTD+XML from a byte array * @return VTDNav * @param ba * @throws IOException * @throws IndexReadException * */ public VTDNav loadIndex(byte[] ba)throws IOException,IndexReadException{ IndexHandler.readIndex(ba,this); return getNav(); } /**
/** * This method loads the VTD+XML from an input stream * @return VTDNav * @param is * @throws IOException * @throws IndexReadException * */ public VTDNav loadIndex(InputStream is) throws IOException,IndexReadException{ IndexHandler.readIndex(is, this); return getNav(); } /**
public class readBytes{ public static void main(String[] s} throws VTDException{ VTDGen vg = new VTDGen(); //get XML Byte array here vg.setDoc(xmlByteArray); vg.parse(); VTDNav vn = vg.getNav(); } }
import com.ximpleware.*; public class getContent { public static void main(String s[]) throws VTDException{ VTDGen vg = new VTDGen(); if (!vg.parseFile("C:\\Users\\HC\\Desktop\\dataset\\book.xml", false)) return; VTDNav vn = vg.getNav(); if (vn.toElement(VTDNav.FIRST_CHILD, "book")){ long l = vn.getContentFragment(); System.out.println( "book content ==> "); System.out.println(vn.toString((int)l, (int)(l<<32))); } } }
import com.ximpleware.*; public class extractValue{ public static void main(String s[]) throws VTDException, IOException{ VTDGen vg = new VTDGen(); if (!vg.parseFile("input.xml", false)); VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.selectXPath("/aa/bb[name='k1']/value"); int i=0; while ((i=ap.evalXPath())!=-1){ System.out.println(" value ===>"+vn.toString(i)); } } }
import com.ximpleware.*; public class removeElement { public static void main(String s[]) throws VTDException{ VTDGen vg = new VTDGen(); if (!vg.parseFile("input.xml", false)) return; VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.selectXPath("/ClOrdIDS/ClOrdID[@id='3']"); int i=0; while((i=ap.evalXPath())!=-1){ } } }
import com.ximpleware.*; public class simpleQuery { public static void main(String[] s) throws Exception{ VTDGen vg = new VTDGen(); if (!vg.parseFile("input.xml", true)) return; VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.selectXPath("//targetChannel/mnemonic/text()"); int i = ap.evalXPath(); if (i!=-1) System.out.println(" result ==>"+vn.toString(i)); } }
import com.ximpleware.*; public class extractValue{ public static void main(String s[]) throws VTDException, IOException{ VTDGen vg = new VTDGen(); if (!vg.parseFile("input.xml", false)); VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.selectXPath("/aa/bb[name='k1']/value"); int i=0; while ((i=ap.evalXPath())!=-1){ System.out.println(" value ===>"+vn.toString(i)); } } }
import com.ximpleware.*; public class xpathSearch { public static void main(String s[])throws VTDException{ VTDGen vg = new VTDGen(); if (!vg.parseFile("d:\\xml\\input.txt", false)) return; VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.selectXPath("/base/parent/*/data[contains(.,'hey')]/../../@id"); int i; while ((i=ap.evalXPath())!=-1) System.out.println("attr id has the value of "+vn.toString(i+1)); } }
import com.ximpleware.*; public class getAttrs{ public static void main(String[] s) throws VTDException{ VTDGen vg = new VTDGen(); if (!vg.parseFile("input.xml",false)) // turn off namespace return; VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.selectXPath("/xml/item/@name"); int i=0; while( (i=ap.evalXPath())!=-1){ System.out.println(" item name is ===>"+vn.toString(i+1)); } } }
VTDGen vg= new VTDGen(); if (vg.parseFile("input.xml",false)){ VTDNav vn = vg.getNav(); vn.toElement(VTDNav.FIRST_CHILD); int i = vn.getText(); if (i!=-1) System.out.println(" text node is "+vn.toString(i)); }
import com.ximpleware.*; public class simpleXpathSearch{ public static void main(String s[]) throws VTDException,java.io.UnsupportedEncodingException,java.io.IOException{ VTDGen vg = new VTDGen(); vg.setLCLevel(5); if (!vg.parseFile("input.xml", false)) return; VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.selectXPath("/*/*[@rsID='1029293']"); int i=0; while((i=ap.evalXPath())!=-1){ // your code logic here }
public static String getXpathValue(String xpath, InputStream is) throws IOException, XPathParseException, ParseException { VTDGen vg = new VTDGen(); vg.setDoc(readStream(is, 1024)); vg.parse(false); return getXpathValue(xpath, vg.getNav()); }
VTDGen vg = new VTDGen(); AutoPilot ap = new AutoPilot(); int i; ap.selectXPath("/root/device/modelname"); if (vg.parseFile(PATH_TO_FILE,true)){ VTDNav vn = vg.getNav(); ap.bind(vn); // apply XPath to the VTDNav instance // AutoPilot moves the cursor for you while((i=ap.evalXPath())!=-1){ System.out.println("the value is: " + vn.toNormalizedString(vn.getText())); } }
VTDGen vg = new VTDGen(); AutoPilot ap = new AutoPilot(); int i; ap.selectXPath("/root/element"); if (vg.parseFile(FILE_LOCATION,true)){ VTDNav vn = vg.getNav(); ap.bind(vn); // apply XPath to the VTDNav instance // AutoPilot moves the cursor for you while((i=ap.evalXPath())!=-1){ System.out.println("the attribute index val is "+ i +" the attribute string ==>"+vn.toString(vn.getAttrVal("attribute"))); } }