public class XMLElement
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
java.util.List<XMLElement> |
find(java.lang.String query) |
XMLElement |
findElement(java.lang.String query) |
java.lang.String |
getAttribute(java.lang.String attrName)
Returns the value of the xml attribute with the given name that
is contained in the given node
|
XMLElement |
getChild(java.lang.String name)
Reads the child node which has the given name from the given parent node
This method assumes that there is a single child node with
the given name under the given parent node, otherwise the first child
found is returned
|
java.util.List<XMLElement> |
getChildren()
Returns the list of child nodes that have the given name from
the given parent node
|
java.util.List<XMLElement> |
getChildren(java.lang.String name)
Returns the list of child nodes that have the given name from
the given parent node
|
java.lang.String |
getChildValue(java.lang.String childName)
Reads the text value contained in the given child node
|
java.lang.String |
getName() |
java.lang.String |
getXML() |
static XMLElement |
parse(org.xml.sax.InputSource in)
Parses the XML file contained in the given input source and reads
the main Document node which is returned from this method
|
static XMLElement |
parse(java.io.InputStream in)
Parses the XML file contained in the given input stream and reads
the main Document node which is returned from this method
|
static XMLElement |
parse(java.io.Reader in)
Parses the XML file contained in the given input stream and reads
the main Document node which is returned from this method
|
public static XMLElement parse(java.io.Reader in) throws java.lang.Exception
in
- the reader to read the XML data fromjava.lang.Exception
- if an error occurs during parsing of the xmlpublic static XMLElement parse(java.io.InputStream in) throws java.lang.Exception
in
- the input stream to read the XML data fromjava.lang.Exception
- if an error occurs during parsing of the xmlpublic static XMLElement parse(org.xml.sax.InputSource in) throws java.lang.Exception
in
- the input source to read the XML data fromjava.lang.Exception
- if an error occurs during parsing of the xmlpublic XMLElement getChild(java.lang.String name)
node
- the parent node to read the child fromname
- the name of the child node to readpublic java.util.List<XMLElement> getChildren()
node
- the parent node to read the child nodes frompublic java.util.List<XMLElement> getChildren(java.lang.String name)
node
- the parent node to read the child nodes fromname
- the name of the child nodes to readpublic java.util.List<XMLElement> find(java.lang.String query) throws javax.xml.xpath.XPathException
javax.xml.xpath.XPathException
public XMLElement findElement(java.lang.String query) throws javax.xml.xpath.XPathException
javax.xml.xpath.XPathException
public java.lang.String getAttribute(java.lang.String attrName)
node
- the node to read the attribute fromattrName
- the name of the attribute whose value is to be retrievedpublic java.lang.String getChildValue(java.lang.String childName)
node
- the parent node to read the child node fromchildName
- the name of the child node whose text value
is to be retrievedpublic java.lang.String getName()
public java.lang.String getXML() throws javax.xml.transform.TransformerException, javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerException
javax.xml.transform.TransformerConfigurationException