我想比较这两个 xml 文件:
文件1.xml:
<ngs_sample id="40332">
<workflow value="salmonella" version="101_provisional" />
<results>
<gastro_prelim_st reason="not novel" success="false">
<type st="1364" />
<type st="9999" />
</gastro_prelim_st>
</results>
</ngs_sample>
文件2.xml:
<ngs_sample id="40332">
<workflow value="salmonella" version="101_provisional" />
<results>
<gastro_prelim_st reason="not novel" success="false">
<type st="1364" />
</gastro_prelim_st>
</results>
</ngs_sample>
我曾经xmldiff
将 a.xml 与 b.xml 进行比较:
def compare_xmls(observed,expected):
from xmldiff import main, formatting
formatter = formatting.DiffFormatter()
diff = main.diff_files(observed,expected,formatter=formatter)
return diff
out = compare_xmls(a.xml, b.xml)
print(out)
输出:
[delete, /ngs_sample/results/gastro_prelim_st/type[2]]
任何人都知道如何识别两个 xml 文件之间的区别,即与文件 b.xml 相比已删除的内容。有人推荐在python中比较xml文件的任何其他方式吗?