Class DOMUtil

java.lang.Object
nl.siegmann.epublib.epub.DOMUtil

class DOMUtil extends Object
Utility methods for working with the DOM.
  • Constructor Details

    • DOMUtil

      DOMUtil()
  • Method Details

    • getAttribute

      public static String getAttribute(Element element, String namespace, String attribute)
      First tries to get the attribute value by doing an getAttributeNS on the element, if that gets an empty element it does a getAttribute without namespace.
      Parameters:
      element -
      namespace -
      attribute -
      Returns:
    • getElementsTextChild

      public static List<String> getElementsTextChild(Element parentElement, String namespace, String tagname)
      Gets all descendant elements of the given parentElement with the given namespace and tagname and returns their text child as a list of String.
      Parameters:
      parentElement -
      namespace -
      tagname -
      Returns:
    • getFindAttributeValue

      public static String getFindAttributeValue(Document document, String namespace, String elementName, String findAttributeName, String findAttributeValue, String resultAttributeName)
      Finds in the current document the first element with the given namespace and elementName and with the given findAttributeName and findAttributeValue. It then returns the value of the given resultAttributeName.
      Parameters:
      document -
      namespace -
      elementName -
      findAttributeName -
      findAttributeValue -
      resultAttributeName -
      Returns:
    • getFirstElementByTagNameNS

      public static Element getFirstElementByTagNameNS(Element parentElement, String namespace, String tagName)
      Gets the first element that is a child of the parentElement and has the given namespace and tagName
      Parameters:
      parentElement -
      namespace -
      tagName -
      Returns:
    • getTextChildrenContent

      public static String getTextChildrenContent(Element parentElement)
      The contents of all Text nodes that are children of the given parentElement. The result is trim()-ed. The reason for this more complicated procedure instead of just returning the data of the firstChild is that when the text is Chinese characters then on Android each Characater is represented in the DOM as an individual Text node.
      Parameters:
      parentElement -
      Returns: