Compare two XML strings ignoring element order

前端 未结 8 1625
陌清茗
陌清茗 2020-12-15 17:23

Suppose I have two xml strings


  a
  b



  b         


        
8条回答
  •  忘掉有多难
    2020-12-15 17:41

    Cross-posting from Compare XML ignoring order of child elements

    I had a similar need this evening, and couldn't find something that fit my requirements.

    My workaround was to sort the two XML files I wanted to diff, sorting alphabetically by the element name. Once they were both in a consistent order, I could diff the two sorted files using a regular visual diff tool.

    If this approach sounds useful to anyone else, I've shared the python script I wrote to do the sorting at http://dalelane.co.uk/blog/?p=3225

提交回复
热议问题