Klasse XmlElementUtil

java.lang.Object
edu.hm.hafner.analysis.util.XmlElementUtil

public class XmlElementUtil extends Object
Provides some useful methods to process the DOM.
Autor:
Ullrich Hafner
  • Methodendetails

    • getChildElementsByName

      public static List<Element> getChildElementsByName(Element parent, String name)
      Returns all elements in the parent that match the specified name.
      Parameter:
      parent - the parent element
      name - the expected name of the childs
      Gibt zurück:
      the elements, the list might be empty if there is no match
    • getFirstChildElementByName

      public static Optional<Element> getFirstChildElementByName(Element parent, String name)
      Returns the first element in the parent that match the specified name.
      Parameter:
      parent - the parent element
      name - the expected name of the childs
      Gibt zurück:
      the first element if there is a match, Optional.empty() otherwise
    • nodeListToList

      public static List<Element> nodeListToList(@CheckForNull NodeList nodeList)
      Convert a NodeList into a List<Element>. Also filters out non elements from the node list.
      Parameter:
      nodeList - node list to convert.
      Gibt zurück:
      list of elements.