Open source command line tool for Linux to diff XML files ignoring element order

后端 未结 6 1533
走了就别回头了
走了就别回头了 2021-02-04 09:57

Is there an open source command-line tool (for Linux) to diff XML files which ignores the element order?

Example input file a.xml:



        
6条回答
  •  鱼传尺愫
    2021-02-04 10:31

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

    That post suggests doing a canonical xml sort then doing a diff. Being that you are on linux, this should work for you cleanly. It worked for me on my mac, and should work for people on windows if they have something like cygwin installed:

    $ xmllint --c14n a.xml > sortedA.xml
    $ xmllint --c14n b.xml > sortedB.xml
    $ diff sortedA.xml sortedB.xml
    

提交回复
热议问题