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
0
votes
0 answers

XMLUnit-2 is failing with `withNodeMatcher` API for random order of List

I've used below DiffBuilder using XMLUnit-2 diff = DiffBuilder.compare(control).withTest(test).checkForSimilar() .normalizeWhitespace().ignoreComments() .ignoreWhitespace().ignoreElementContentWhitespace() .withNodeFilter(node -> (filter(node,…
Swapnil Kotwal
  • 5,418
  • 6
  • 48
  • 92
0
votes
2 answers

XMLUnit - compare xml and ignore few tags based on a condition

I have couple of xmls which needs to be compared with different set of similar xml and while comparing i need to ignore tags based on a condition, for example personal.xml - ignore fullname address.xml - igone zipcode contact.xml - ignore…
0
votes
0 answers

Skip comparison xml order between two xml documents

I have two xml documents and the content in those documents same. But in one document namespaces order is different when comparing with other xml. I need to skip the order of the namespaces when comparing via soapui. Im using xmlunit
Subodhya
  • 9
  • 4
0
votes
1 answer

Java compare XML tags with different names

I have two XML's which have basically the same content but a single tag has a different name: actualSource: aaaa
Maciej eM
  • 41
  • 8
0
votes
0 answers

Can I compare two XML files with slightly different structure using XMLUnit?

I have XML file with the following structure: -1 Citygroup
0
votes
1 answer

XMLUnit-2.0 xpath doesn't ignoring the XML node order

I've a XML as below
Swapnil Kotwal
  • 5,418
  • 6
  • 48
  • 92
0
votes
1 answer

XMLUnit-2 ignore certain nested XML elements

My XML is little complex and I've to ignore certain entry from the comparison, how would I able to achieve it ?
Swapnil Kotwal
  • 5,418
  • 6
  • 48
  • 92
0
votes
1 answer

XMLUnit-2 compare partial XMLs

I have a local test XML data as below testLocalXML something different something else yet another thing but the data I'm getting from server could be large and will…
Swapnil Kotwal
  • 5,418
  • 6
  • 48
  • 92
0
votes
1 answer

XMLUnit throws NullPointerException when creating Diff object for valid xml

I am using org.custommonkey.xmlunit; (version 1.2). While building Diff object: Diff diff = new Diff(expected, generated); I always have NullPointerException as it's failing on this.controlDoc = this.getManipulatedDocument(controlDoc);. While…
Michu93
  • 5,058
  • 7
  • 47
  • 80
0
votes
1 answer

XMLUnit compare XML not working where parent node contains multiple child nodes of same name and attributes list but different attribute values

I am using XMLUnit to compare two XMLs to detect the updates. My pom is as : xmlunit xmlunit 1.6 For most of the scenarios, XMLUnit is working…
0
votes
1 answer

How can I compare map-like elements with XMLUnit

I have below xml data: Control: Name1 Value1
anuni
  • 889
  • 10
  • 26
0
votes
1 answer

How to determine if two XML files have the same structure even if the tags have different values?

I wish to compare two XML files and determine if they have the same structure i.e. The same type and number of tags with preferably the same attributes. The value of the tags and attributes may be different. This code detects ALL the differences.…
0
votes
1 answer

DiffBuilder - ignore element value but make sure the XML node is present

I am using DiffBuilder to compare two XML files. For the given element Product, I want to check that the element is present but I want to ignore its value. Is it possible using XmlUnit ? My code below will work regardless of the presence of the…
Frederic
  • 2,015
  • 4
  • 20
  • 37
0
votes
2 answers

Getting Out of memory error while comparing two large xml files

I am trying to compare two large XML files uisng XMLUNIT, but I am getting "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space" public static void main(String[] args) throws Exception { FileReader file = new…
Nitesh
  • 1,477
  • 5
  • 23
  • 34
0
votes
2 answers

Comparing two similar XML data with unordered elements/attributes in Java

I'm looking for an API which compares two XML data. I've tried XMLUnit 2 but couldn't find a way to make it work properly with my example. Could you give me an example which works for my need? My first XML data xml1:
gokan
  • 1,028
  • 1
  • 14
  • 30