Class DOMUtil
java.lang.Object
nl.siegmann.epublib.epub.DOMUtil
Utility methods for working with the DOM.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetAttribute(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.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.static StringgetFindAttributeValue(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.static ElementgetFirstElementByTagNameNS(Element parentElement, String namespace, String tagName) Gets the first element that is a child of the parentElement and has the given namespace and tagNamestatic StringgetTextChildrenContent(Element parentElement) The contents of all Text nodes that are children of the given parentElement.
-
Constructor Details
-
DOMUtil
DOMUtil()
-
-
Method Details
-
getAttribute
-
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
-
getTextChildrenContent
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:
-