我想比较这两个xml文件:
File1.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>
File2.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文件吗?