Class DOMUtils

    • Method Detail

      • getChildElements

        public static List<ElementgetChildElements​(Element element)
        Retrieves all child elements of the given DOM element.
        Parameters:
        element - The DOM element to analyze
        Returns:
        a List of child elements instances
      • getFirstChildElement

        public static Element getFirstChildElement​(Element element)
        Get the first child element of the given DOM element.
        Parameters:
        element - The DOM element to analyze
        Returns:
        the first child element or null if there is no child element
      • getUniqueChildElements

        public static List<ElementgetUniqueChildElements​(Element element)
        Retrieves some child elements of the given DOM element If some elements have the same tag name, only the first of these elements is retrieved
        Parameters:
        element - the DOM element to analyze
        Returns:
        a List of child elements instances
      • getChildElementsByTagName

        public static List<ElementgetChildElementsByTagName​(Element element,
                                                              String name)
        Retrieves all child elements of the given DOM element that match the given element name. Only look at the direct child level of the given element. Do not go into further depth (in contrast to the DOM API's getElementsByTagName method).
        Parameters:
        element - The DOM element to analyze
        name - The child element name to look for
        Returns:
        a List of child elements instances
      • getChildElementByTagName

        public static Element getChildElementByTagName​(Element element,
                                                       String name)
        Retrieves the first child element of the given DOM element that matches the given element name. Only look at the direct child level of the given element. Do not go into further depth.
        Parameters:
        element - The DOM element to analyze
        name - The child element name to look for
        Returns:
        the first child element instance
      • hasChildElement

        public static boolean hasChildElement​(Element element,
                                              String name)
        Checks if the given DOM element has a child element that matches the given element name.
        Parameters:
        element - The DOM element to analyze
        name - The child element name to look for
        Returns:
        true if the given DOM element has a child element that matches the given element name, false otherwise