Vishwa
Vishwa

Reputation: 117

Can we merge two xml files using stax

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 

Upvotes: 1

Views: 634

Answers (1)

greenkode
greenkode

Reputation: 3996

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.

Upvotes: 1

Related Questions