public final class ElementHelper extends Object
Modifier and Type | Method and Description |
---|---|
static String |
getAttribute(Element node,
String key)
Return the value of an element attribute.
|
static String |
getAttribute(Element node,
String key,
String def)
Return the value of an element attribute.
|
static Element |
getChild(Element root,
String name)
Return a named child relative to a supplied element.
|
static Element[] |
getChildren(Element root)
Return all children of the supplied parent.
|
static Element[] |
getChildren(Element root,
String name)
Return all children matching the supplied element name.
|
static Element |
getRootElement(InputStream input)
Return the root element of the supplied input stream.
|
static String |
getValue(Element node)
Return the value of an element.
|
public static Element getRootElement(InputStream input) throws ParserConfigurationException, IOException, SAXException
input
- the input stream containing a XML definitionIOException
- If an underlying I/O problem occurred.ParserConfigurationException
- if there is a severe problem in the XML parsing subsystem.SAXException
- If the XML is malformed in some way.public static Element getChild(Element root, String name)
root
- the parent DOM elementname
- the name of a child elementpublic static Element[] getChildren(Element root, String name)
root
- the parent DOM elementname
- the name against which child element will be matchedpublic static Element[] getChildren(Element root)
root
- the parent DOM elementpublic static String getValue(Element node)
node
- the DOM nodepublic static String getAttribute(Element node, String key)
node
- the DOM nodekey
- the attribute keyCopyright © 2006–2019 OPS4J - Open Participation Software for Java. All rights reserved.