Xml comparison in Python

Posted by Gregg Lind on Stack Overflow See other posts from Stack Overflow or by Gregg Lind
Published on 2010-06-09T15:33:25Z Indexed on 2010/06/09 16:22 UTC
Read the original article Hit count: 347

Filed under:
|
|

Building on another SO question, how can one check whether two well-formed XML snippets are semantically equal. All I need is "equal" or not, since I'm using this for unit tests.

In the system I want, these would be equal (note the order of 'start' and 'end'):

<?xml version='1.0' encoding='utf-8' standalone='yes'?>
<Stats start="1275955200" end="1276041599">
</Stats>

# Reodered start and end

<?xml version='1.0' encoding='utf-8' standalone='yes'?>
<Stats end="1276041599" start="1275955200" >
</Stats>

I have lmxl and other tools at my disposal, and a simple function that only allows reordering of attributes would work fine as well!

© Stack Overflow or respective owner

Related posts about python

Related posts about Xml