xmlunit

Java: How do I ignore certain elements when comparing XML?

I have an XML message like so: <root> <elementA>something</elementA> <elementB>something else</elementB> <elementC>yet another thing</elementC> </root> I want to compare a message of this type produced by a method under test to an expected message, but I don't care about elementA. So, I'd like the above message to be considered...

How can I compare two similar XML files in XMLUnit

Hi I am trying to use XMLUnit to compare two similar XML files. Basically every thing is same. File1 is a copy of File2. But in File2 I have changed the order of some elements in one node. Now I am trying to run a test where it compares these files and returns a result of "similar" and not treat these files as "different". Can you pl...

How to catch AssertPathsEqual and print error to console?

How could I catch this AssertionFailedError and print to the console an message that says: "Expected text value '55555' but was '55556' at /xpathResult[1]/result[2]/field[1]/field[1]/field[6]/text()[1] for [testFileName] and [testName]" I'm not exactly sure how to catch the values out from the assertion without having to "hack" and man...

JUnit Test if XML Document is sorted on arbitrary column

Given an xml document like <root> <row> <a>2</a> <b>1</b> <c>8</c> </row> <row> <b>5</b> <a>2</a> <c>8</c> </row> <row> <a>2</a> <c>8</c> <b>6</b> </row> </root> Is there an easy way to assert that the XML document is sorted on element B in XMLUnit Edit: I have an odd problem with a pie...

Testing XML with XMLUnit with a variable value.

I have some XML which I am testing, which has set as one of it's elements the date and time. This obviously will change every time the test is run. Is there a way to compare the XML and have this node value ignored, or just checked with a regular expression or something. The XML I am testing is as follows: <xml-fragment> <core:da...

Ignore few children for comparison when comparing xml documents with XMLUnit

Hi, Is it possible to ignore few children in elements when comparing xml documents with xmlunit. i want to ignore any empty text nodes in the element when comparing them. Best Regards, Keshav ...

XMLUnit - Compare two XML ignoring the child order

Hello, I am trying to see if I could use XMLUnit to compare the following two different XML. I used the Diff class to compare the following two XML and checking for similar returns false. XML One <Required> <Question desc="Are you single?"> <Answers> <Answer value="Yes"/> <Answer value="No"/> </Answers> ...