How to compare XML files

后端 未结 5 1555
你的背包
你的背包 2021-02-19 11:50

I have two XML files (XSD) which are generated by some tool.
The tool doesn\'t preserve the order of elements so although the content is equal comparing it as text will resu

5条回答
  •  眼角桃花
    2021-02-19 12:30

    I had a similar problem and I eventually found: http://superuser.com/questions/79920/how-can-i-diff-two-xml-files

    That post suggests doing a canonical XML sort then doing a diff. The following should work for you if you are on Linux, Mac, or if you have Windows with something like Cygwin installed:

    $ xmllint --c14n FileA.xml > 1.xml
    $ xmllint --c14n FileB.xml > 2.xml
    $ diff 1.xml 2.xml
    

提交回复
热议问题