How to compare XML files

后端 未结 5 1725
遇见更好的自我
遇见更好的自我 2021-02-19 11:44

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:37

    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
    

提交回复
热议问题