public class XmlParserHelper
extends java.lang.Object
| Modifier | Constructor and Description |
|---|---|
protected |
XmlParserHelper()
Defines a XML parser helper.
|
| Modifier and Type | Method and Description |
|---|---|
org.w3c.dom.Element |
getChild(org.w3c.dom.Element parent,
java.lang.String name)
Get from parent the direct child with the given tag name.
|
java.util.List<org.w3c.dom.Element> |
getChildren(org.w3c.dom.Element parent,
java.lang.String name)
Get from parent all children for the given tag name.
|
java.lang.String |
getChildText(org.w3c.dom.Element parent,
java.lang.String name)
Safe getting of the content as a text value from the child with the given
tag name.
|
boolean |
getChildTextAsBoolean(org.w3c.dom.Element parent,
java.lang.String name)
Safe getting of the content as a boolean value from the child with the
given tag name.
|
java.util.Date |
getChildTextAsDate(org.w3c.dom.Element parent,
java.lang.String name)
Safe getting of the content as a date value from the child with the given
tag name.
|
double |
getChildTextAsDouble(org.w3c.dom.Element parent,
java.lang.String name)
Safe getting of the content as a double value from the child with the
given tag name.
|
int |
getChildTextAsInt(org.w3c.dom.Element parent,
java.lang.String name)
Safe getting of the content as a integer value from the child with the
given tag name.
|
long |
getChildTextAsLong(org.w3c.dom.Element parent,
java.lang.String name)
Safe getting of the content as a long value from the child with the given
tag name.
|
java.util.Date |
getChildTextAsShortDate(org.w3c.dom.Element parent,
java.lang.String name)
Safe getting of the content as a short value from the child with the
given tag name.
|
java.lang.String |
getName(org.w3c.dom.Node n)
Returns the name of the node.
|
java.lang.String |
getText(org.w3c.dom.Node n)
Returns the content of the node and removes their path from the verifier.
|
org.w3c.dom.Document |
parseXml(org.xml.sax.InputSource inputSource)
Parses the XML stream to a
Document. |
org.w3c.dom.Document |
parseXml(java.lang.String xml)
Parses the text XML to a
Document. |
void |
verify()
Checks if the content of all parsed nodes was picked up.
|
protected XmlParserHelper()
public void verify()
throws XmlVerifierException
XmlVerifierException - thrown if the content of not all nodes was picked up.public org.w3c.dom.Document parseXml(java.lang.String xml)
throws XmlParserHelperException
Document.xml - the xmlXmlParserHelperException - thrown in case of any XML parsing exceptionspublic org.w3c.dom.Document parseXml(org.xml.sax.InputSource inputSource)
throws XmlParserHelperException
Document.inputSource - the input sourceXmlParserHelperException - thrown in case of ParserConfiguration, SAX and IO exceptionspublic java.lang.String getText(org.w3c.dom.Node n)
n - nodepublic java.lang.String getName(org.w3c.dom.Node n)
n - nodepublic org.w3c.dom.Element getChild(org.w3c.dom.Element parent,
java.lang.String name)
parent - parent nodename - child tag namepublic java.util.List<org.w3c.dom.Element> getChildren(org.w3c.dom.Element parent,
java.lang.String name)
parent - parent nodename - the children tag namepublic java.lang.String getChildText(org.w3c.dom.Element parent,
java.lang.String name)
parent - parent XML elementname - the child name the content should be picked uppublic double getChildTextAsDouble(org.w3c.dom.Element parent,
java.lang.String name)
parent - parent XML elementname - the child name the content should be picked uppublic long getChildTextAsLong(org.w3c.dom.Element parent,
java.lang.String name)
parent - parent XML elementname - the child name the content should be picked uppublic int getChildTextAsInt(org.w3c.dom.Element parent,
java.lang.String name)
parent - parent XML elementname - the child name the content should be picked uppublic boolean getChildTextAsBoolean(org.w3c.dom.Element parent,
java.lang.String name)
parent - parent XML elementname - the child name the content should be picked uppublic java.util.Date getChildTextAsDate(org.w3c.dom.Element parent,
java.lang.String name)
parent - parent XML elementname - the child name the content should be picked uppublic java.util.Date getChildTextAsShortDate(org.w3c.dom.Element parent,
java.lang.String name)
parent - parent XML elementname - the child name the content should be picked up