I have different methods trying to update/remove elements/tokens based on the path.
Right now, each method, after it done edited, it straight away save as a file,
VTDGen vg = new VTDGen();
vg.parseFile("input.xml", false);
vn.getNav();
AutoPilot ap = new AutoPilot(vn);
XMLModifier xm;
public void updateToken(String path)
{
xm = new XMLModifier(vn);
ap.selectXPath(path);
......
xm.updateToken(i,"hello");
......
xm.output("output.xml");
}
And if I continue to call this method again, it does save, but it overwrites the file with the new changes, and I do not want that, so how can I do it?
I have also tried using
xm.outputAndReparse();
where I save the update back to NTDNav vn
, and reuse for the remaining methods but it corrupts the rest of the method's movement to the node (with AutoPilot).
What I want: Call the method to update the token based on the path, save the update, and call the method again with another path, and finally after finishing the update, save into the file.
Please do let me know if I am in any wrong, as I am still new to VTD-XML. Thanks.
Got it working and this is what I have done.
VTDGen vg = new VTDGen();
vg.parseFile("input.xml", false);
vn.getNav();
AutoPilot ap = new AutoPilot(vn);
XMLModifier xm = new XMLModifier(vn);
public void output()
{
....
xm.output("output.xml");
....
}
public void updateToken(String path)
{
ap.selectPath(path);
.........
xm.updateToken(i,"hello");
}