I've got XML-data generated by a tool which I want to diff against data created earlier by the same tool. The problem is that the tool might reorder elements within the XML-data and thus I need some way to tell the diff tool to base its match on one or more attributes of the elements. I've got access to Beyond Compare 2 but haven't been able to setup any rule which does this. I've considered doing some kind of XML transformation to sort the elements before giving the data to the diff tool but it doesn't feel like a good solution.
So my question is if anyone can give a tips of a tool which can perform the diff or a good way to sort the data so it becomes suitable for usage with Beycond Compare? Below is a small example of the XML-data.
<document Model="Model 1" UUID="e795782b-6be0-4c4a-9a23-217a96fef230">
<Target Name="Example target" UUID="bed4836e-1868-4997-9537-d98a182e7311" >
<Thread Name="Thread 1" UUID="199e8627-db04-4e7c-9643-bb4eeb2faf11"></Thread>
<Thread Name="Thread 2" UUID="366c9fe5-790a-44fd-bbae-e91fa2faeaaf"></Thread>
<Mutex Name="Mutex 1" UUID="23423434-324a-2344-2343-423423423423"></Mutex>
<Mute开发者_如何学JAVAx Name="Mutex 2" UUID="230d2068-2367-7955-4567-345902904590"></Mutex>
</Target>
</document>
If you use Java a nice hack would be to use XMLUnit they have an object called XmlDiff ...
精彩评论