0
我想比較的2 XML文件的XML樹結構:Python的XML比較樹的
文件1:
<?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?><DATA>
<Time>2016-02-12T00:00:00.211Z</Time>
<Item>
<ID>123456789</ID>
<VAR1>897654564dDJUHFKHJHEU</VAR1>
</Item>
<Check>OK</Check>
</DATA>
文件2:
<?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?><DATA>
<Time>2016-02-13T00:05:00.531Z</Time>
<Item>
<ID>888555444</ID>
<VAR1>ABCD_MKLS8866dee6</VAR1>
</Item>
<Check>FAILED</Check>
</DATA>
我的代碼:
from lxml import etree
tree1 = etree.parse('file1.xml')
tree2 = etree.parse('file2.xml')
print(tree1.getroot())
print(tree2.getroot())
print set(tree1.getroot()) == set(tree2.getroot())
當我比較它們的結果== false。結果應該是== true ... 如何才能比較樹結構而不使用值?