// This java app will make // The input XML (serve as a template) looks like this: /* some content */ // The output XML looks like this: /* 123 234 new content */ import com.ximpleware.*; import java.io.*; public class overWrite { public static void main(String[] args) throws Exception { VTDGen vg = new VTDGen(); if (vg.parseFile("old.xml",false)){ VTDNav vn = vg.getNav(); if (vn.toElement(VTDNav.FIRST_CHILD)){ // cursor at int i = vn.getText(); if (vn.overWrite(i," 123".getBytes())==false){ System.out.println("overWrite at "+i+" failed"); } // cursor at vn.toElement(VTDNav.NEXT_SIBLING); i = vn.getText(); if (vn.overWrite(i," 234".getBytes())==false){ System.out.println("overWrite at "+i+" failed"); } // cursor at vn.toElement(VTDNav.NEXT_SIBLING); i = vn.getText(); if (vn.overWrite(i,"new content".getBytes())==false){ System.out.println("overWrite at "+i+" failed"); } byte[] ba = vn.getXML().getBytes(); FileOutputStream fos = new FileOutputStream("new.xml"); fos.write(ba); } } } }