Unless you tell XMLUnit to ignore whitespace "element content whitespace" like linebreaks between elements or spaces used for indentation may cause a different number of children.
When looking up differences I'd recommend you go by the type of comparison rather than the text. "child nodelist sequence" is the CHILD_NODELIST_SEQUENCE comparison which is used to compare the order of nodes. In your case it says whatever is the second child in your control node has been matched to the first child in the test node so the order is different.
Judging from the two messages I'd guess there is an empty whitespace-only text node right after the opening element tag in your control document that is not present in the test document.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using DifferenceEngine differenceEngine = new DOMDifferenceEngine(); to compare so how do I configure XMLunit to ignore the whitepace. I dont see this method in DifferenceEngine. Sorry I am new so I am asking low level details as well.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thank you very much. If I downgrade difference to equal the the text differences r not highlighted. i read the DifferenceEvaluator user guide. It says diferent order of child nodes are considered similar. this is what i want so i will leave it as default. now i am facing a problem where in it thinks 42 and 42.00000 are different, 0.5 and 0.500 are differernt. is there anything available in Xmlunit to overcome this ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am using 2.5.1 XML Unit. When I compare two XMLs' I get the following
Expected child nodelist length '13' but was '15'
Expected child nodelist sequence '2' but was '1'
When I count the no of child nodes in both the XMLs' I do not see any difference. So what does this mean?
What does nodelist sequence mean?
Please help.
Unless you tell XMLUnit to ignore whitespace "element content whitespace" like linebreaks between elements or spaces used for indentation may cause a different number of children.
When looking up differences I'd recommend you go by the type of comparison rather than the text. "child nodelist sequence" is the
CHILD_NODELIST_SEQUENCEcomparison which is used to compare the order of nodes. In your case it says whatever is the second child in your control node has been matched to the first child in the test node so the order is different.Judging from the two messages I'd guess there is an empty whitespace-only text node right after the opening element tag in your control document that is not present in the test document.
thanks for the info.
I understand that there are two types of ignore white spaces (setIgnoreWhitespace and setNormalizeWhitespace ). I will go with setIgnoreWhitespace (referred - http://xmlunit.sourceforge.net/userguide/html/ar01s03.html#Comparing:%20Configuration)
I am using DifferenceEngine differenceEngine = new DOMDifferenceEngine(); to compare so how do I configure XMLunit to ignore the whitepace. I dont see this method in DifferenceEngine. Sorry I am new so I am asking low level details as well.
also is there a way to disable checking the nodelist sequece?
Your link is to the user guide of XMLUnit 1.x, the one for 2.x is https://github.com/xmlunit/user-guide/wiki
When using the DifferenceEngine directly, whitespace handling needs to be done at the source level, You'd wrap your input into a
WhiteSpaceStrippedSource. The alternative is to useDiffBuilderwithignoreWhitespace- see https://github.com/xmlunit/user-guide/wiki/DiffBuilderA difference in sequence causes a
ComparisonResult.SIMILARoutcome, you can downgrade it toEQUALby overriding theDifferenceEvaluatorwhich can be created via https://github.com/xmlunit/xmlunit/blob/master/xmlunit-core/src/main/java/org/xmlunit/diff/DifferenceEvaluators.java#L133 for example.thank you very much. If I downgrade difference to equal the the text differences r not highlighted. i read the DifferenceEvaluator user guide. It says diferent order of child nodes are considered similar. this is what i want so i will leave it as default. now i am facing a problem where in it thinks 42 and 42.00000 are different, 0.5 and 0.500 are differernt. is there anything available in Xmlunit to overcome this ?
I will open another conversation for this topic. thanks a lot for all your inputs.