Class XmlUtil

java.lang.Object
io.github.microcks.util.XmlUtil

public class XmlUtil extends Object
Helper methods for parsing/navigating an Xml DOM.
Author:
laurent
  • Field Details

  • Method Details

    • getDirectChildren

      public static List<Element> getDirectChildren(Element parent, String namespace, String tag)
      Retrieve direct children elements of a parent having specified namespace and tag. Only includes level 1 children.
      Parameters:
      parent - The parent of children to find
      namespace - The namespace of children
      tag - The tag of children
      Returns:
      Children Elements as a list
    • getUniqueDirectChild

      public static Element getUniqueDirectChild(Element parent, String namespace, String tag) throws MalformedXmlException
      Retrieve a direct child that is expected to be unique under the parent. Throws a MalformedXmlException if no child or more than one child present.
      Parameters:
      parent - The parent of child to find
      namespace - The namespace of child
      tag - The tag of child
      Returns:
      The child Element
      Throws:
      MalformedXmlException - if no child or more than one child present.
    • hasDirectChild

      public static boolean hasDirectChild(Element parent, String namespace, String tag)
      Check if parent has at least one direct child having namespace and tag.
      Parameters:
      parent - The parent of children to find
      namespace - The namespace of children
      tag - The tag of children
      Returns:
      true if at least one child is present, false otherwise