Menu

Comparing attribute values

Help
mxtthias
2010-04-06
2013-03-03
  • mxtthias

    mxtthias - 2010-04-06

    The following test fails:

    @Test
    public void testDiffSimilar() throws Exception
    {
    String a = "<a><b val=\"c\" /><b val=\"d\" /></a>";
    String b = "<a><b val=\"d\" /><b val=\"c\" /></a>";
    Diff diff = new Diff(a, b);
    assertTrue(diff.similar());
    }

    What would I need to do to make the comparison work?

     
  • Stefan Bodewig

    Stefan Bodewig - 2010-04-07

    You need to help XMLUnit to determine which XML elements it should compare.  By default it will compare elements with the same element names in order.

    You want to specify a custom ElementQualifier http://xmlunit.sourceforge.net/userguide/html/ar01s03.html#ElementQualifier - to be specific in your case you want to use a ElementNameAndAttributeQualifier.

     
  • mxtthias

    mxtthias - 2010-04-08

    Thanks! That solved my problem.

     

Log in to post a comment.