Package de.umass.xml
Class DomElement
java.lang.Object
de.umass.xml.DomElement
DomElement wraps around an Element and provides convenience methods.- Author:
- Janni Kovacs
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAttribute(String name) Returns the attribute value to a given attribute name ornullif the attribute doesn't exist.Returns the child element with the given name ornullif it doesn't exist.getChildren(String name) Returns all children of this element with the given tag name.getChildText(String name) Returns the text content of a child node with the given name.Returns this element's tag name.getText()booleanhasAttribute(String name) Tests if this element has an attribute with the specified name.booleanChecks if this element has a child element with the given name.
-
Constructor Details
-
DomElement
Creates a new wrapper around the givenElement.- Parameters:
elem- An w3c Element
-
-
Method Details
-
getElement
- Returns:
- the original Element
-
hasAttribute
Tests if this element has an attribute with the specified name.- Parameters:
name- Name of the attribute.- Returns:
trueif this element has an attribute with the specified name.
-
getAttribute
Returns the attribute value to a given attribute name ornullif the attribute doesn't exist.- Parameters:
name- The attribute's name- Returns:
- Attribute value or
null
-
getText
- Returns:
- the text content of the element
-
hasChild
Checks if this element has a child element with the given name.- Parameters:
name- The child's name- Returns:
trueif this element has a child element with the given name
-
getChild
Returns the child element with the given name ornullif it doesn't exist.- Parameters:
name- The child's name- Returns:
- the child element or
null
-
getChildText
Returns the text content of a child node with the given name. If no such child exists or the child does not have text content,nullis returned.- Parameters:
name- The child's name- Returns:
- the child's text content or
null
-
getChildren
- Returns:
- all children of this element
-
getChildren
Returns all children of this element with the given tag name.- Parameters:
name- The children's tag name- Returns:
- all matching children
-
getTagName
Returns this element's tag name.- Returns:
- the tag name
-