Based on the question I have ask earlier: How can you save the constant update and the finally save the output as a file with XMLModifier
The previous question I have done is do all the update and finally output it into a XML by xm.ouput("output.xml");
I know you have mention that:
One operation per offset value: two repeating operations at the same offset will cause exception
Example, I probably a list of path I would like to edit, but I have forgotten there would be duplicate. I wouldnt know until there is error and a exception is produce.
VTDGen vg = new VTDGen();
vg.parseFile("input.xml", false);
vn.getNav();
AutoPilot ap = new AutoPilot(vn);
XMLModifier xm = new XMLModifier(vn);
public void updateToken(String path, String value)
{
ap.selectPath(path);
.........
xm.updateToken(i,value);
}
public static void main(String args[])
{
updateToken("/a/b/c", "hello");
//updateToken("/a/b", "world");(*ignore)
updateToken("/a/b/c", "john");
}
But is there a way 2nd update possible to? By overwriting, or there is a method to check that that point is being updated? Any suggestions?
I have a XML file something like this.
<a>
<b>
<c>value1</c>
</b>
<b>
<c>value2</c>
</b>
</a>
I decided to use the first updateToken("/a/b/c", "hello")
to update only the 2nd C node - value2 -> hello
And the next updateToken("/a/b/c", "john")
to update both of the C node. The output I gotten was:
<a>
<b>
<c>john</c>
</b>
<b>
<c>hello</c>
</b>
</a>
And later produces an exception, which I know there is two operation happening on the same offset. So I am wondering, is it possible to not even do the 2nd updateToken()
since there has been one update on that offset
Like do a search for update marking before starting to mark, if not, there will be some update here and there...