Class DOMUtils
java.lang.Object
org.apache.lucene.queryparser.xml.DOMUtils
Helper methods for parsing XML
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleangetAttribute(Element element, String attributeName, boolean deflt) static floatgetAttribute(Element element, String attributeName, float deflt) static intgetAttribute(Element element, String attributeName, int deflt) static StringgetAttribute(Element element, String attributeName, String deflt) static StringgetAttributeOrFail(Element e, String name) static StringgetAttributeWithInheritance(Element element, String attributeName) Returns an attribute value from this node, or first parent node with this attribute definedstatic Stringstatic ElementgetChildByTagName(Element e, String name) static ElementgetChildByTagOrFail(Element e, String name) static StringgetChildTextByTagName(Element e, String tagName) static ElementgetFirstChildElement(Element element) static Elementstatic Stringstatic Stringstatic ElementinsertChild(Element parent, String tagName, String text) static DocumentHelper method to parse an XML file into a DOM tree, given a reader.
-
Constructor Details
-
DOMUtils
public DOMUtils()
-
-
Method Details
-
getChildByTagOrFail
- Throws:
ParserException
-
getFirstChildOrFail
- Throws:
ParserException
-
getAttributeOrFail
- Throws:
ParserException
-
getAttributeWithInheritanceOrFail
public static String getAttributeWithInheritanceOrFail(Element e, String name) throws ParserException - Throws:
ParserException
-
getNonBlankTextOrFail
- Throws:
ParserException
-
getChildByTagName
-
getAttributeWithInheritance
Returns an attribute value from this node, or first parent node with this attribute defined- Returns:
- A non-zero-length value if defined, otherwise null
-
getChildTextByTagName
-
insertChild
-
getAttribute
-
getAttribute
-
getAttribute
-
getAttribute
-
getText
-
getFirstChildElement
-
loadXML
Helper method to parse an XML file into a DOM tree, given a reader.- Parameters:
is- reader of the XML file to be parsed- Returns:
- an org.w3c.dom.Document object
-