Compare two XML strings ignoring element order

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

Suppose I have two xml strings


  a
  b



  b         


        
8条回答
  •  我在风中等你
    2020-12-15 17:44

    For xmlunit 2.0 (I was looking for this) it is now done, by using DefaultNodeMatcher

    Diff diff = Diffbuilder.compare(Input.fromFile(control))
       .withTest(Input.fromFile(test))
       .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText))
       .build()
    

    Hope this helps this helps other people googling...

提交回复
热议问题