File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XMLUnit for comparing XML

 
Sneha Teck
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Job at hand is to compare 2 XML files.
The result expected is not only an assertion of whether the XMLs are similar or different but also to present the various differences.
This to be done irrespective to the position of the various XML records.

Based on my understanding of XMLUnit, it provides only assertion type results.
has anyone implemented XMLUnit not just as a testing tool but also for purely comparing XML files.

If yes then I would appreciate the help to explore XMLUnit beyond my understanding.

Thanks & Regards,
Sneha.
 
Sneha Teck
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Example for the XML comparision

-------------
XML-1
-------------
<result>
<item_tuple>
<itemno>1001</itemno>
<desc>Red Bicycle</desc>
</item_tuple>
<item_tuple>
<itemno>1002</itemno>
<desc>Racing Bicycle</desc>
<quantity>5</quantity>
</item_tuple>
<item_tuple>
<itemno>1003</itemno>
<desc>Next Bicycle</desc>
<quantity>5</quantity>
</item_tuple>
</result>

-------------
XML-2
-------------
<result>
<item_tuple>
<itemno>1002</itemno>
<desc>Racing Bicycle</desc>
</item_tuple>
<item_tuple>
<itemno>1006</itemno>
<desc>Learning Bicycle</desc>
</item_tuple>
<item_tuple>
<itemno>1001</itemno>
<desc>Old Bicycle</desc>
</item_tuple>
</result>

Record - 1001 is different , due to the value for node 'desc'
Record 1003 && 1006 to be displayed as not present in the other .
record 1002 differ due to the existence of tag <quantity>


 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.

Does DetailedDiff not do what you need? In any case, as you point out, this really isn't what XMLUnit is for--have you considered using an XML diff tool? When I search the web I find many.
 
Sneha Teck
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David,

Thank You for your input.
The need is to explore the XMLUnit. Hence no diff tools.
 
praneel shah
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use beyond compare software, it will give you all the differnces and many other functioalities...
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic