1

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 compare the objects within one xml bundle file.

Don't know if this makes sense. If more info is needed, I can try explain more.

Sample of the xml file:

<mo>FIELD</mo>
<pk1>DM_READEXTRACT</pk1>
<bo>F1-FieldPhysicalBO</bo>
<boData> 
  <field>DM_READEXTRACT</field>
  <dataType>CHAR</dataType>
  <isSigned>false</isSigned>
  <isWorkField>false</isWorkField>
  <version>9</version>
</boData>
<entities> 
  <processingSequence>560</processingSequence>
  <sequence>560</sequence>
</entities>
<mo>FIELD</mo>
<pk1>DM_READEXTRACT</pk1>
<bo>F1-FieldPhysicalBO</bo>
<boData> 
  <field>DM_READEXTRACT</field>
  <dataType>CHAR</dataType>
  <isSigned>false</isSigned>
  <isWorkField>false</isWorkField>
  <version>2</version>
</boData>
<entities> 
  <processingSequence>30</processingSequence>
  <sequence>3</sequence>
</entities>
mnille
  • 1,328
  • 4
  • 16
  • 20
Shekinah
  • 11
  • 3

2 Answers2

0

Maybe try to unmarshall XML to java objects and than compare? http://www.mkyong.com/java/jaxb-hello-world-example/

Maciej Laskowski
  • 697
  • 1
  • 5
  • 7
0

XMLUnit works on Nodes as well - at least 2.x does.

By looking at your example, what you want to compare is not a proper tree but a forrest - there is no root element all others are children of.

What you can do is creating a DocumentFragment for each forrest you want to compare (on both the test and control sides) and add all roots of your forrest to it - and then tell XMLUnit to work on the DocumentFragments. You can obtain an instance of a DocumentFragment by first loading the DOM Document and then calling createDocumentFragment on it.

Stefan Bodewig
  • 3,260
  • 15
  • 22