Quick example on how to calculate the difference between two XML files, regardless of node order. Also takes node attributes into account.
It does this by converting the XML in each file to an array, sorting the array and then creating XML from the sorted array. It then uses PHP-Diff to calculate and display the diff between the sorted XML.
You can try it out here.
Given the following two XML files
1.xml:
<xml>
<twee>
<d/>
<c an-attribute="another value"></c>
</twee>
<een>
<b>
Some more content
</b>
<a>
Some content
</a>
</een>
</xml>
2.xml:
<xml>
<een>
<a>
Some content
</a>
<b>
Some more content
</b>
</een>
<twee>
<c an-attribute="a different value" second-attribute="a value also" first-attribute="a value"></c>
<d/>
<e></e>
</twee>
</xml>
The output would be:
Old Version | New Version | ||
---|---|---|---|
9 | </b> | 9 | </b> |
10 | </een> | 10 | </een> |
11 | <twee> | 11 | <twee> |
12 | <c an-attribute="a | 12 | <c an-attribute="a different value" first-attribute="a value" second-attribute="a value also"/> |
13 | <d/> | 13 | <d/> |
14 | <e/> | ||
14 | </twee> | 15 | </twee> |
15 | </root> | 16 | </root> |
16 | 17 |