Note that there are some explanatory texts on larger screens.

plurals
  1. POXMLUnit Compare Xml Ignoring Sequence
    primarykey
    data
    text
    <p>I need to compare 2 XML's for which I am using my custom Difference Listener which is ignoring Child Node Sequence and Attribute List Sequence:</p> <pre><code>if (difference.getId() == DifferenceConstants.CHILD_NODELIST_SEQUENCE_ID || difference.getId() == DifferenceConstants.ATTR_SEQUENCE_ID) return DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL; </code></pre> <p>My code works well for :</p> <pre><code> &lt;xml&gt; &lt;elem1 att1="abc" att2="def"&gt;&lt;/elem1&gt; &lt;elem1&gt;&lt;/elem1&gt; &lt;/xml&gt; </code></pre> <p>and</p> <pre><code> &lt;xml&gt; &lt;elem1&gt;&lt;/elem1&gt; &lt;elem1 att2="def" att1="abc"&gt;&lt;/elem1&gt; &lt;/xml&gt; </code></pre> <p>However I need it to consider these XML's as identical as well:</p> <pre><code>&lt;xml&gt; &lt;elem1&gt; &lt;elem2&gt; &lt;id&gt;ABC&lt;/id&gt; ..... &lt;/elem2&gt; &lt;/elem1&gt; &lt;elem1&gt; &lt;elem2&gt; &lt;id&gt;DEF&lt;/id&gt; ..... &lt;/elem2&gt; &lt;/elem1&gt; &lt;/xml&gt; </code></pre> <p>and </p> <pre><code>&lt;xml&gt; &lt;elem1&gt; &lt;elem2&gt; &lt;id&gt;DEF&lt;/id&gt; ..... &lt;/elem2&gt; &lt;/elem1&gt; &lt;elem1&gt; &lt;elem2&gt; &lt;id&gt;ABC&lt;/id&gt; ..... &lt;/elem2&gt; &lt;/elem1&gt; &lt;/xml&gt; </code></pre> <p>Here I want comparison to consider both elem1's in both XML are identical as only sequence is mixed up. So I need my code to work for more than one nesting level. Is that possible with XMLUnit? Please help anyone ?</p> <p>I found a temporary Solution (Cant add Comment on my own ques for 8 hrs):</p> <p>I was earlier overriding the ElementQualifier with: ElementNameAndAttributeQualifier, If I change that to RecursiveElementNameAndTextQualifier, I can get my desired result</p> <pre><code>xmlDiff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier()); </code></pre> <p>You can also use multiLevelElementNameandTextQualifier for deepr level XML compare. Recursive is for level 1 only.</p> <p>For further Details your can refer: <a href="http://xmlunit.sourceforge.net/userguide/html/ar01s03.html#ElementQualifier" rel="nofollow">http://xmlunit.sourceforge.net/userguide/html/ar01s03.html#ElementQualifier</a> Example 20</p> <p>I need to match Element Name and Attributes and this matches Name and Text .. but still .. for now its working so I am using it ..</p> <p>Will update if I find better solution</p> <p>Hope this is helpful for someone :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload