Compare two XML strings ignoring element order

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

Suppose I have two xml strings


  a
  b



  b         


        
8条回答
  •  遥遥无期
    2020-12-15 17:42

    For me, I also needed to add the method : checkForSimilar() on the DiffBuilder. Without it, the assert was in error saying that the sequence of the nodes was not the same (the position in the child list was not the same)

    My code was :

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

提交回复
热议问题