I want to compare in groovy code my Soap Response with xml file ignoring order :
Here is my code :
import org.custommonkey.xmlunit.Stuff
import org.xmlunit.Stuff
//ExpectedString is my xml converted to text, same for ResponseString
Diff diff = DiffBuilder.compare(ExpectedString)
.withTest(ResponseString)
.ignoreComments()
.ignoreWhitespace()
.checkForSimilar()
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName))
.build();
assertFalse("XML similar " + diff.toString(), diff.hasDifferences())
So, as you can see, I used DefaultNodeMatcher, I used XMLUnit2.0 ... with no result (even not ignoring order or having exception error while comparing)
Is there a solution ? to resolve this
As I'm desperate to find a direct one, can I sort my xml and my soap response so i can have a simple diff ? is there a way to sort it line by line alphabetically ? If yes, how ?
Thank you guys !
Update :
Here is my XML structure simplified
<body>
<stuff>
<miniStuff></miniStuff>
<miniStuff></miniStuff>
</stuff>
<Services>
<Service>
<tag1>ValueA</tag1>
<tag2>ValueAA</tag2>
</Service>
<Service>
<tag1>ValueB</tag1>
<tag2>ValueBB</tag2>
</Service>
</services>
</body>
My problem is I can't guarantee that ValueA is the first one and not the second