Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

VTD-XML ; XML splitting.

jack
2013-09-17
2013-09-17
  • jack
    jack
    2013-09-17

    Hi,

    I would like to navigate to a specific node in the xml after reading the xml. lets assume the xml has
    [<root><test></test><test></test><test></test>....</root>] , now my program reads few nodes for e.g : 5 and then it creates a output file. I now need to go back to the position in the xml file where the cursor left to read 5 more files to create a new output file again .. this process has to continue untill i reach the end by reading 5 elements everytime.

    All my files that gets created has the same first 5 nodes in all the xmls..

    int counter=0;
    vn= vg.getNav();
    AutoPilot ap0 = new AutoPilot();
    ap0.selectXPath("/root/A");
    ap0.bind(vn);
    while(counter < 100 ){ //99 files are to be written
    writeFile(ap0, vn)
    }

    my write file method :-

    byte[] ba = vn.getXML().getBytes();
    int i=0;

    while (i<5 && ap0.evalXPath() != -1) {
    long l = vn.getElementFragment();
    int offset = (int) l;
    int len = (int) (l >> 32);
    fos.write('\n');
    fos.write(ba, offset, len);
    i++;
    }
    vn.push();

    all my 100 files has same 5 nodes,,,,any help? what is the way to set the navigation cursor to 6th ,11th, and so on ....elements in the next iterations...

    any help pls.
    thanks
    }

     
    Last edit: jack 2013-09-17