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 ornull
if the attribute doesn't exist.Returns the child element with the given name ornull
if 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()
boolean
hasAttribute
(String name) Tests if this element has an attribute with the specified name.boolean
Checks 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:
true
if this element has an attribute with the specified name.
-
getAttribute
Returns the attribute value to a given attribute name ornull
if 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:
true
if this element has a child element with the given name
-
getChild
Returns the child element with the given name ornull
if 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,null
is 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
-