Class XPathHelper
- java.lang.Object
-
- com.smartgridready.communicator.common.helper.XPathHelper
-
public class XPathHelper extends java.lang.ObjectProvides helper methods for XML and XPath.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringconvertNodeToString(org.w3c.dom.Node node)Converts a DOM node to a string.static org.w3c.dom.DocumentconvertXmlToDocument(java.lang.String xmlResp)Loads an XML string into a documentstatic ValueparseXmlResponse(java.lang.String xPath, java.lang.String xmlResp)Evaluates an XPath expression on an XML string and returns as SGr value.
-
-
-
Method Detail
-
convertXmlToDocument
public static org.w3c.dom.Document convertXmlToDocument(java.lang.String xmlResp) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOExceptionLoads an XML string into a document- Parameters:
xmlResp- the XML string- Returns:
- an instance of
Document - Throws:
javax.xml.parsers.ParserConfigurationException- when the document parser could not be initializedorg.xml.sax.SAXException- when the document could not be parsedjava.io.IOException- when an other error occurred
-
convertNodeToString
public static java.lang.String convertNodeToString(org.w3c.dom.Node node) throws javax.xml.transform.TransformerExceptionConverts a DOM node to a string.- Parameters:
node- the DOM node- Returns:
- a string
- Throws:
javax.xml.transform.TransformerException- when transformation failed
-
parseXmlResponse
public static Value parseXmlResponse(java.lang.String xPath, java.lang.String xmlResp) throws com.smartgridready.driver.api.common.GenDriverException
Evaluates an XPath expression on an XML string and returns as SGr value.- Parameters:
xPath- the XPath expressionxmlResp- the XML string- Returns:
- an instance of
StringValue - Throws:
com.smartgridready.driver.api.common.GenDriverException- when an error occurred during parsing
-
-