Service Virtualization

  • 1.  Tech Tips: DevTest Graphical XML Side-by-Side Comparison (XML Compare Options)

    Broadcom Employee
    Posted Oct 09, 2015 10:55 AM

    Question:

     

    For XML Compare Options, how would one ignore the element itself? I have an 'optional' element, and if it's not there, it's fine, however ignore nodes seems to only ignore the contents of an element, not an element itself.

    Answer:


    Using the following 2 simple XMLs to explain:

     

     

    XML A:

      <?xml version="1.0" encoding="UTF-8"?>

      <shipto>

        <name>Ola Nordmann</name>

        <address>Langgt 23</address>

        <city>4000 Stavanger</city>

      </shipto>

     

     

    XML B:

      <?xml version="1.0" encoding="UTF-8"?>

      <shipto>

        <address>Langgt 23</address>

        <city>4000 Stavanger</city>

    </shipto>

     

     

    The difference between them is that the name element is missing in XML B.

     

    When the name element is marked to be ignored, the existing source code handles it properly and ignores the element. 

     

    However another compare option, "Ignore child element ordering", seems to be interfering. 

     

    By default, this option is turned off, so the ordering (i.e. indexes) of element’s children is enforced.

     

    In he above example, the index of the address element in XML A is 1, but it’s 0 in XML B because the name element is missing. As such the compare fails.

     

    Note that this means that ordering would no longer be considered, but if an element is optional as in this case, the ordering would not match anyway.



  • 2.  Re: Tech Tips: DevTest Graphical XML Side-by-Side Comparison (XML Compare Options)

    Posted Oct 12, 2015 04:59 AM

    in the "Ignored Nodes" setting of the XML side-by-side assertion, use an xpath that is independent from the index of your element. For example "//name" and also check the box "Ignore child element ordering".

    On my instance (8.3), it works.



  • 3.  Re: Tech Tips: DevTest Graphical XML Side-by-Side Comparison (XML Compare Options)

    Broadcom Employee
    Posted Oct 12, 2015 02:46 PM

    In the XML, right click on the node and select Ignore option. This will automatically  add XPath to the Ignore nodes.

     

    To ignore the element text, click on the "Settings" tab and check the "Ignore element text" check box.



  • 4.  Re: Tech Tips: DevTest Graphical XML Side-by-Side Comparison (XML Compare Options)

    Posted Jun 28, 2016 07:39 AM

    I use this Assertion to compare XML's, how to get differences in some properties or write the result to some file?