/** * New in v2.12 * Dump an element fragment of xml into an output stream * @param os * @throws NavException * @throws IOException */ final public void dumpFragment(OutputStream os) throws NavException, IOException{ long l = getElementFragment(); dumpFragment(l,os); }
/** * New in v2.12 * Dump an element fragment of xml into an XML file whose name is specified as fileName * @param fileName * @throws NavException * @throws FileNotFoundException * @throws IOException */ final public void dumpFragment(String fileName) throws NavException, FileNotFoundException,IOException{ long l = getElementFragment(); dumpFragment(l,fileName); } /**
FileOutputStream fios = new FileOutputStream("file"+j+".xml"); vn.dumpFragment(fios);// write the product fragment fios.write(ba); if (vn.toElement(VTDNav.NEXT_SIBLING,"priceBracket")){ vn.dumpFragment(fios); vn.toElement(VTDNav.PREV_SIBLING);
import com.ximpleware.*; import java.io.*; public class gandalf { public static void main(String a[]) throws VTDException, Exception{ VTDGen vg = new VTDGen(); if (vg.parseFile("c:\\xml\\gandalf.txt", false)){ VTDNav vn=vg.getNav(); AutoPilot ap = new AutoPilot(vn); ap.selectXPath("/company/staff[nickname]"); int i=-1; int count=0; while((i=ap.evalXPath())!=-1){ vn.dumpFragment("c:\\xml\\staff"+count+".xml"); count++; } } } }