Problem while comparing two documents

Help
2011-07-08
2013-03-03
  • Ahmed Dhieb
    Ahmed Dhieb
    2011-07-08

    Hi,

    I'm trying to compare two xml documents using xmlunit 1.3.

    The first is :
    <a>
        <b>
            <c>text</c>
            <d>text</d>
        </b>
        <e>
            <f>text</f>
            <g>text</g>
        </e>
    </a>

    and

    <a>
        <e>
            <g>text</g>
            <f>text</f>
        </e>
        <b>
            <c>text</c>
            <d>text</d>
        </b>
    </a>

    So elements in level 1 can be in different order (b and e). Besides, elements in level 2 can also be in different order (g and f)

    How can I do to have as a result similar and not identical ?

    Thanks

    Ahmed

     
  • Stefan Bodewig
    Stefan Bodewig
    2011-07-15

    The part of XMLUnit which decides which node to compare to which other node is controlled by the  ElementQualifier.  In your case it should work if you just used the ElementNameQualifier to make sure XMLUnit will compare the sub-trees with the same root names.