xml - XmlUnit and Child Nodes -


i using xmlunit compare 2 text files. control xml is:

<books>     <book>        <name>angels &amp; demons</name>        <isbn>9971-5-0210-0</isbn>        <author>dan brown</author>        <category></category>     </book> </books> 

i comparing against piece of xml has , elements swapped.

<books>     <book>         <isbn>9971-5-0210-0</isbn>         <name>angels &amp; demons</name>         <author>dan brown</author>         <category></category>     </book> </books> 

the diff object reports following difference:

expected sequence of child nodes '1' '3' - comparing <name...> @ /books[1]/book[1]/name[1] <name...> @ /books[1]/book[1]/name[1] 

if <name> child node '1', wouldn't <isbn> child node '2'?

for xmlunit 2.x version:

for xmlunit 2.xx version, xmlunit.setignorewhitespace(true) not anymore applicable. now, can add "ignoring whitespace" directly diffbuilder adding diffbuilder.ignorewhitespace().

diff diffxml =diffbuilder.compare(expectedxml).withtest(actualxml).normalizewhitespace().checkforsimilar().build(); 

for asserting xmls similar can eg. do:

   matcherassert.assertthat(diffxml.tostring(), is("[identical]")); 

for furhter info changes between 1.x 2.x see: https://github.com/xmlunit/user-guide/wiki/migrating-from-xmlunit-1.x-to-2.x


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

php - Dynamic url re-writing using htaccess -

java - Multi-Label Document Classification -