Package nl.siegmann.epublib.epub
Class DOMUtil
- java.lang.Object
-
- nl.siegmann.epublib.epub.DOMUtil
-
class DOMUtil extends java.lang.ObjectUtility methods for working with the DOM.
-
-
Constructor Summary
Constructors Constructor Description DOMUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetAttribute(org.w3c.dom.Element element, java.lang.String namespace, java.lang.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.static java.util.List<java.lang.String>getElementsTextChild(org.w3c.dom.Element parentElement, java.lang.String namespace, java.lang.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 java.lang.StringgetFindAttributeValue(org.w3c.dom.Document document, java.lang.String namespace, java.lang.String elementName, java.lang.String findAttributeName, java.lang.String findAttributeValue, java.lang.String resultAttributeName)Finds in the current document the first element with the given namespace and elementName and with the given findAttributeName and findAttributeValue.static org.w3c.dom.ElementgetFirstElementByTagNameNS(org.w3c.dom.Element parentElement, java.lang.String namespace, java.lang.String tagName)Gets the first element that is a child of the parentElement and has the given namespace and tagNamestatic java.lang.StringgetTextChildrenContent(org.w3c.dom.Element parentElement)The contents of all Text nodes that are children of the given parentElement.
-
-
-
Method Detail
-
getAttribute
public static java.lang.String getAttribute(org.w3c.dom.Element element, java.lang.String namespace, java.lang.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 java.util.List<java.lang.String> getElementsTextChild(org.w3c.dom.Element parentElement, java.lang.String namespace, java.lang.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 java.lang.String getFindAttributeValue(org.w3c.dom.Document document, java.lang.String namespace, java.lang.String elementName, java.lang.String findAttributeName, java.lang.String findAttributeValue, java.lang.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 org.w3c.dom.Element getFirstElementByTagNameNS(org.w3c.dom.Element parentElement, java.lang.String namespace, java.lang.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 java.lang.String getTextChildrenContent(org.w3c.dom.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:
-
-