Compare content of two XML files

David Brochu brochu121 at gmail.com
Tue Aug 18 15:51:45 CEST 2009


I need to compare a REST XML response with a 'gold standard' response (one
that we have already verified is correct). The problem is, sometimes the
REST response comes back and it is logically correct, but the order of
attributes and elements is different than what is in the 'gold standard'
file. For example:

'Gold Standard':
<?xml version="1.0"    encoding="UTF-8" standalone="yes"?>
<Response>
    <Service id="1523"/>
    <CustomerInformation>
        <Networks>
            <Network CUR="EUR" LOC="GB" type="text"/>
        </Networks>
</Response>

REST Response:
<?xml version="1.0"  standalone="yes" encoding="UTF-8"?>
<Response>
    <Service id="1523"/>
    <CustomerInformation>
        <Networks>
            <Network type="text" CUR="EUR" LOC="GB" />
        </Networks>
</Response>
Notice how the attributes in <xml> and <network> are in different order. The
response is correct, but obviously doesn't match the 'gold standard'.

Does anyone know how I would be able to compare these two files and verify
they match, even though the order of attributes and elements may be
different between the two? Is there a module I should be using for this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090818/051d4064/attachment.html>


More information about the Python-list mailing list