Wednesday, 4 September 2013

Update node of XML string without using DOM parser

Update node of XML string without using DOM parser

I would like to update a particular node of an input XML string. Is there
a way to achieve this without using the DOM parser ?
The reason for not considering DOM is because of memory consumption as the
XML I am trying to parse is large. I have tried out STAX but it does not
have a simple way of doing this.
This is the sample XML:
<parent>
<children>
<child>
<id>1</id>
</child>
<child>
<id>2</id>
</child>
<child>
<id>1</id>
</child>
<child>
<id>2</id>
</child>
</children>
</parent>
Now, after update the output XML should look like this, with the duplicate
IDs removed: 1 2
So in this case I would have to rewrite the complete "children" node with
no duplicates. Please suggest a way.

No comments:

Post a Comment