I have two xml files I want to compare with a match. But I want to use embedded expressions / only define what I'm looking for in the expected xml file. I don't want to write specific match for this scenario as I want to have a large scenario outline with many xml files that can be totally unique.
In my example, I'm interested in only matching Item1
and not any other items. The list can be out of order. How can I achieve this?
My expected xml:
<Something>
<Items>
<Item1 Code="123">
<SubItem></SubItem>
</Item1>
#ignore
</Items>
</Something>
My actual xml:
<Something>
<Items>
<Item2 Code="123">
<SubItem></SubItem>
</Item2>
<Item1 Code="123">
<SubItem></SubItem>
</Item1>
</Items>
</Something>
EDIT:
I would like to only use fuzzy matching.
I see a case like #[] bar.bar
in other examples, referencing a def in the karate scenario. But I would like to do #[] <Item1></<Item1>
so that everything is self contained in the XML file, so that the structure I want to match against is still defined in the xml.
My expected XML would look like this then:
<Something>
<Items>
#[] <Item1 Code="123">
<SubItem></SubItem>
</Item1>
</Items>
</Something>
Where I would hope I could define something like this which says, match that Items
is an array/collection of elements and Items
contains this specific element.
#[] <Item1 Code="123">
<SubItem></SubItem>
</Item1>