public class XMLParseUtil extends Object
| Constructor and Description |
|---|
XMLParseUtil() |
| Modifier and Type | Method and Description |
|---|---|
static DocumentBuilder |
getDocumentBuilder()
Returns a
DocumentBuilder, which is used for parsing XML
documents. |
static String |
getElementData(Element root,
String elementName)
Gets the text value of the specified element.
|
static String |
getElementData(Node node)
Static helper function to get the element data of the specified node.
|
static String |
getStringFromElement(Element doc) |
static Element |
loadXmlResource(InputStream in)
Loads the imput stream and returns the root element.
|
static Element |
loadXmlResource(String fileName)
Loads the xml file into an xml document and returns the root element.
|
public static String getElementData(Node node)
node - the node where the text data resides; may be null
in which case this funtion will return ""nullpublic static String getElementData(Element root, String elementName)
root - the root of the element whose text is to be retrieved; assumed
not to be null.elementName - the name of the element whose text is to be retrieved.public static Element loadXmlResource(String fileName) throws Exception
fileName - the fully qualified name of the XML file to load; assumed not
to be null.null.Exception - on any errorpublic static Element loadXmlResource(InputStream in) throws Exception
in - Input Stream.null.Exception - on any errorpublic static DocumentBuilder getDocumentBuilder()
DocumentBuilder, which is used for parsing XML
documents.DocumentBuilder which is used for parsing XML
documents. Never null.public static String getStringFromElement(Element doc) throws TransformerException
TransformerExceptionCopyright © 2018. All Rights Reserved.