Questions tagged [xmlunit]

XMLUnit is an open source project which enables JUnit-style assertions to be made about the content and structure of XML.

XMLUnit extends and to enable unit testing of XML.

It compares a control XML document to a test document or the result of a transformation, validates documents, and compares the results of expressions.

XMLUnit for Java

XMLUnit for Java provides two JUnit extension classes, XMLAssert and XMLTestCase, and a set of supporting classes (e.g. Diff, DetailedDiff,Transform,SimpleXpathEngine,Validator,NodeTest) that allow assertions to be made about:

  • The differences between two pieces of XML
  • The outcome of transforming a piece of XML using XSLT
  • The evaluation of an XPath expression on a piece of XML
  • The validity of a piece of XML
  • Individual nodes in a piece of XML that are exposed by DOM Traversal

XMLUnit for Java can also treat HTML content (even badly-formed HTML) as valid XML to allow these assertions to be made about the content of web pages too.

XMLUnit is available for and .

184 questions
1
vote
1 answer

Matching tags with identical names but different child values

I am trying to use XMLUnit 2 to compare xml files. 1 2 Second file is the same,…
gore_obsessed
  • 146
  • 2
  • 11
1
vote
1 answer

Compare two xml's using XMLUnit bypassing the order of elements

I am writing a comparison util which lets me compare similarity of two xmls without considering the order. Am using xmlunit 2.4.0 org.xmlunit.diff.Diff diff = DiffBuilder.compare(xml1) .withTest(xml2) …
paulophoenix
  • 89
  • 1
  • 10
1
vote
1 answer

xmlunit: Error with ElementSelectors.conditionalBuilder

So I have the following input, expected output and actual output xml: input.xml Main Contact & No Reported To 1/6/2017 11:25:45 AM
jbailie1991
  • 1,305
  • 2
  • 21
  • 42
1
vote
0 answers

how to select particular nodes to assert using xml unit

I am comparing the xml files for a component . There I have some nodes which i need to compare. But I dont need all the nodes to be compared. So i there any way in xmlunit so that I can compare only those particular nodes. I use nodefilter and…
1
vote
4 answers

Compare Xml in java unit text, ignoring an attribute in a node

I have to compare 2 xml strings. Actual
1
vote
1 answer

Ignore all elements not present in the test XML with XMLUnit

In XMLUnit 2.x, can I ignore all elements in the actual ("control") XML that are not present in my test ("expected") XML? Example: Actual: 123 456 789 Test: 456 xxx I would want to detect the difference in
jhyot
  • 3,733
  • 1
  • 27
  • 44
1
vote
1 answer

Ignore certain elements while compating xml XMLUnit

I want to compare two XML in one of the Junit test. I am using XMLUnit for comparison of xml.Can you please tell me if there is any easy way to ignore comparison of correlation-id in the xmls. XML1:
Ravi
  • 1,247
  • 4
  • 15
  • 35
1
vote
0 answers

Comparing two XML Strings

I am having 2 XML documents as…
1
vote
0 answers

Not able to compare empty tags/elements in which one is self closed tag with attribute value and other one is normal tag with no attribute

Out put of Difference is : Expected attribute name 'nil' but was 'null' - comparing at…
1
vote
1 answer

Ignore few children for comparison when comparing xml documents with XMLUnit

Is it possible to ignore a 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
keshav84
  • 2,291
  • 5
  • 25
  • 34
1
vote
2 answers

Comparing xml objects java

I have an xml bundle file which I would like to read through and compare the objects within the bundle. The start position would be the mo tag until the next mo tag. I have done xmlunit but this compares 2 xml files. I would like to be able to…
Shekinah
  • 11
  • 3
1
vote
1 answer

Compare subnodes in XMLUnit 2 - Expected child 'node2' but was 'null'

I need to compare XML files using XMLUnit 2 where xml subnodes can differ in order. Due to the underlying libraries that are used I can't influence order of subnodes. For comparison I am using:
ksokol
  • 8,035
  • 3
  • 43
  • 56
1
vote
1 answer

Ignore a multiple occurrence of a tag while comparing using xmlUnit

I have an XML file which looks like below. Expected XML a.c 10 c b.h 14 h d.he
user3540481
  • 221
  • 3
  • 13
1
vote
1 answer

Does XMLUNIT provide option to ignore certain elements in XML's for comparison?

I am wondering if XMLUNIT provides a way to ignore some of the elements present in the XML before doing the comparison.For example, if I want to ignore field which is randomly generated by the server.Is there anything available out of the box in…
Torukmakto
  • 340
  • 1
  • 3
  • 11
1
vote
1 answer

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…
Xetius
  • 44,755
  • 24
  • 88
  • 123