I have a requirement of merging two xml files.I am trying to investigate using stax parser. I am just concerned with only few particular elements as remaining elements are same in both the xml files. For example: A.xml
<report>
<measurement event-id="2170014015"/>
<measurement event-id="2170014021"/>
</report>
B.xml
<report>
<measurement event-id="2170014011"/>
<measurement event-id="2170014013"/>
<measurement event-id="2170014015"/>
</report>
Output:
<report>
<measurement event-id="2170014015">
<measurement event-id="2170014021">
<measurement event-id="2170014011">
<measurement event-id="2170014013">
</report>
These are for understanding purpose(but xml files are pretty big). What is the opinion on using jaxb
If these files are really big, then I wouldn't recommend JAXB. Unless you're going to throw a ton of RAM at it. StAX will be the preferable option. See this tutorial on how to merge multiple documents usin StAX.