For example, say I have two XML Strings that I want to merge:
<Test>
<A>false</A>
<B>true</B>
<C>Transfers!</C>
</Test>
<Test2>
<A>false</A>
<B>false</B>
</Test2>
Where the final result looks like (notice, B is now false, because I would like a place to do some sort of logic to determine the final "merged values", in this example, a method would take in two strings, false, and true, and do some AND logic and return "false")
<Test>
<A>false</A>
<B>false</B>
<C>Transfers!</C>
</Test>
I am thinking of either doing it all by hand, using JAX-B & XPath, or XStream Marshal/Unmarshallers. Does anyone have an example of the best & most dynamic way to do this?
The element names will change, they will not always be "A" and "B", but the two XML strings I pass in will always have some elements in common, but sometimes one XML String/Document may have one or more elements that don't exist in the other document, and in this case those need to be in the final XML result as is.
A
andB
elements, and a serialization and deserialization process that converts the object to and from the XML string. Once you have that, the final solution should be trivial. Unless, of course, you want to go the whole "parse it by hand, write it back out by hand" route. But you still need to do some math, so having object representations makes that much easier.