比较两个XML文件,而不考虑它们的顺序 [英] comparing two xml files irrespective of their order

查看:191
本文介绍了比较两个XML文件,而不考虑它们的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在一个python项目,并停留在一个小问题与使用python比较两个XML文件。现在假设我们有两个xml文件:

I am currently working on a python project and stuck in one little problem related to comparison of two XML files using python. Now for instance assume that we have two xml files:

一个文件:

<m1:time timeinterval="5">
   <m1:vehicle distance="40" speed="5"\>

   <m1:location hours = "1" path = '1'\>
      <m1:feature color="2" type="a">564</m1:feature>
      <m1:feature color="3" type="b">570</m1:feature>
      <m1:feature color="4" type="c">570</m1:feature>
   <\m1:location>

   <m1:location hours = "5" path = '1'\>
      <m1:feature color="6" type="a">560</m1:feature>
      <m1:feature color="7" type="b">570</m1:feature>
      <m1:feature color="8" type="c">580</m1:feature>   
   <\m1:location>

   <m1:location hours = "9" path = '1'\>
      <m1:feature color="10" type="a">560</m1:feature>
      <m1:feature color="11" type="b">570</m1:feature>
      <m1:feature color="12" type="c">580</m1:feature>   
   <\m1:location>
</m1:time>

B档案:

<m1:time timeinterval="6">
   <m1:vehicle distance="40" speed="5"\>

   <m1:location hours = "5" path = '1'\>
      <m1:feature color="6" type="a">560</m1:feature>
      <m1:feature color="7" type="b">570</m1:feature>
      <m1:feature color="8" type="c">580</m1:feature>   
   <\m1:location>

   <m1:location hours = "1" path = '1'\>
      <m1:feature color="2" type="a">564</m1:feature>
      <m1:feature color="3" type="b">570</m1:feature>
      <m1:feature color="4" type="c">570</m1:feature>
   <\m1:location>

   <m1:location hours = "9" path = '1'\>
      <m1:feature color="10" type="a">560</m1:feature>
      <m1:feature color="11" type="b">570</m1:feature>
      <m1:feature color="12" type="c">580</m1:feature>   
   <\m1:location>

</m1:time>



查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆