For XML Compare Options, how would one ignore the element itself? I have an 'optional' element, and if it's not there, it's fine, however ignore nodes seems to only ignore the contents of an element, not an element itself. Answer:
Using the following 2 simple XMLs to explain:
<?xml version="1.0" encoding="UTF-8"?>
The difference between them is that the name element is missing in XML B.
When the name element is marked to be ignored, the existing source code handles it properly and ignores the element.
However another compare option, "Ignore child element ordering", seems to be interfering.
By default, this option is turned off, so the ordering (i.e. indexes) of element’s children is enforced.
In he above example, the index of the address element in XML A is 1, but it’s 0 in XML B because the name element is missing. As such the compare fails.
Note that this means that ordering would no longer be considered, but if an element is optional as in this case, the ordering would not match anyway.
in the "Ignored Nodes" setting of the XML side-by-side assertion, use an xpath that is independent from the index of your element. For example "//name" and also check the box "Ignore child element ordering".
On my instance (8.3), it works.
In the XML, right click on the node and select Ignore option. This will automatically add XPath to the Ignore nodes.
To ignore the element text, click on the "Settings" tab and check the "Ignore element text" check box.
I use this Assertion to compare XML's, how to get differences in some properties or write the result to some file?