Style information in XMLUnit

Help
2008-10-20
2013-03-03
  • Hi,

    I am trying to compare two HTML DOM documents. One has different styling information on a div element than the other, and when that difference is detected I would like to use the Node object for something else. Unfortunately the Node is not a child of the div element but a (stand-alone) node STYLE without a parent.

    Is there a way to find the place in the DOM of this node?

    Best regards, Cor-Paul

     
    • Update: I just noticed that this is also the case for other attributes, for example the action attribute of a form. Is this correct?

      Imho this information should be a child node of the html element it belongs to.

       
      • Stefan Bodewig
        Stefan Bodewig
        2008-10-20

        the Node should be an org.w3c.dom.Attr and its getOwnerElement should not be null.

        In general, XMLunit doesn't modify the Nodes so "normal" DOM traversal is supposed to work.

         
        • Stefan Bodewig
          Stefan Bodewig
          2008-10-20

          see the JavaDoc of Node#getParentNode, where it says

          "The parent of this node. All nodes, except Attr, Document, DocumentFragment, Entity, and Notation may have a parent."

          I have no clear idea why the DOM group decided to add a new method to travel from attribute to element and make the one that feels natural defunct.

           
        • Ah I goofed here; I was using getParentNode() instead of getOwnerElement() for attributes. Thanks :)