Java: Easiest way to compare two xmls

1.3k views Asked by At

I have two xmls:

first.xml

<text>This is text</text>
<output>This is output</output>

second.xml

<text>This is not text</text>
<output>This is output</output>

I want to compare these two xmls and output should like this

<text>This is <inserted>not</inserted> text</text>
    <output>This is output</output>

Means, I want to add a new tag suppose <inserted> to newly added text. How to compare these xmls and create new one ?

Thanks for ur time :)

2

There are 2 answers

0
Stephen C On

Take a look at diffxml.

3
AudioBubble On

http://xmlunit.sourceforge.net/

Nice to use in Unit tests, very good output.