Class XmlNodeUtil


  • public class XmlNodeUtil
    extends java.lang.Object
    Utility class for working with a document object model and an XmlNode.
    Since:
    2.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.w3c.dom.Element findChild​(org.w3c.dom.Node parent, XmlNode target, int offset)
      Finds the Nth matching child of a DOM element.
      static org.w3c.dom.Element findSibling​(org.w3c.dom.Element sibling, XmlNode target)
      Returns a sibling element that matches a given definition, or null if no match is found.
      static java.lang.String getAttribute​(org.w3c.dom.Element element, XmlNode definition)
      Returns the value of an attribute for an element.
      static java.lang.String getText​(org.w3c.dom.Node node)
      Returns the child text from a DOM node.
      static boolean isNil​(org.w3c.dom.Element element)
      Tests if an element is nil.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isNil

        public static boolean isNil​(org.w3c.dom.Element element)
        Tests if an element is nil.
        Parameters:
        element - the element to test
        Returns:
        true if the element is nil
      • getAttribute

        public static java.lang.String getAttribute​(org.w3c.dom.Element element,
                                                    XmlNode definition)
        Returns the value of an attribute for an element.
        Parameters:
        element - the element to check
        definition - the definition of the attribute to retrieve from the element
        Returns:
        the defined attribute value, or null if the attribute was not found on the element
      • getText

        public static java.lang.String getText​(org.w3c.dom.Node node)
        Returns the child text from a DOM node.
        Parameters:
        node - the node to parse
        Returns:
        the node text, or null if the node did not contain any text
      • findSibling

        public static org.w3c.dom.Element findSibling​(org.w3c.dom.Element sibling,
                                                      XmlNode target)
        Returns a sibling element that matches a given definition, or null if no match is found.
        Parameters:
        sibling - the sibling DOM element to begin the search
        target - the node to search for
        Returns:
        the matching element, or null if not found
      • findChild

        public static org.w3c.dom.Element findChild​(org.w3c.dom.Node parent,
                                                    XmlNode target,
                                                    int offset)
        Finds the Nth matching child of a DOM element.
        Parameters:
        parent - the parent DOM node
        target - the node to search for
        offset - the occurrence of the matching node
        Returns:
        the matching element, or null if no match is found