I have 2 SimpleXMLElement
s. They both have the same elements (identical ID attributes), but different tags, and I want to merge them together.
Is there any SimpleXML function I can use to do this, or will I have to loop through all the elements to generate a new SimpleXmlElement?
File 1
<Elements>
<Element ID="352">
<SomeTag35>Some value</SomeTag35>
<SomeTag99>Some other value</SomeTag99>
</Element>
<Element ID="353">
<SomeTag35>A value</SomeTag35>
<SomeTag99>Another value</SomeTag99>
</Element>
</Elements>
File 2
<Elements>
<Element ID="352">
<SomeTag15>Value</SomeTag15>
<SomeTag44>Value2</SomeTag44>
</Element>
<Element ID="353">
<SomeTag15>Value</SomeTag15>
<SomeTag44>Value</SomeTag44>
</Element>
</Elements>
I'm looking to some how end up with
<Elements>
<Element ID="352">
<SomeTag35>Some value</SomeTag35>
<SomeTag99>Some other value</SomeTag99>
<SomeTag15>Value</SomeTag15>
<SomeTag44>Value</SomeTag44>
</Element>
<Element ID="353">
<SomeTag35>A value</SomeTag35>
<SomeTag99>Another value</SomeTag99>
<SomeTag15>Value</SomeTag15>
<SomeTag44>Value</SomeTag44>
</Element>
</Elements>