首页 > 解决方案 > 最好使用 Python 比较两个 XML 文件

问题描述

对于任何额外的行,我需要比较两个具有相同结构的 XML 文件。下面的示例提供了一些详细信息:

文件 1:

<Log1> Some text here </Log1>
<Log2>
      <Id1> Some text here </Id1>
      <Id2> Some text here </Id2>
</Log2>

文件2:

<Log1> Some text here </Log1>
<Log2>
      <Id1> Some text here </Id1>
      <Id2> Some text here </Id2>
</Log2>
<Log3> Some text here </Log3>

我需要 diff 来确定 File2 中有一个额外的标签。在 Python 中这样做有效率吗?

标签: pythonxmlxml-parsing

解决方案


推荐阅读