Class XPathHelper


  • public class XPathHelper
    extends java.lang.Object
    Provides helper methods for XML and XPath.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String convertNodeToString​(org.w3c.dom.Node node)
      Converts a DOM node to a string.
      static org.w3c.dom.Document convertXmlToDocument​(java.lang.String xmlResp)
      Loads an XML string into a document
      static Value parseXmlResponse​(java.lang.String xPath, java.lang.String xmlResp)
      Evaluates an XPath expression on an XML string and returns as SGr value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.IOException
        Loads 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 initialized
        org.xml.sax.SAXException - when the document could not be parsed
        java.io.IOException - when an other error occurred
      • convertNodeToString

        public static java.lang.String convertNodeToString​(org.w3c.dom.Node node)
                                                    throws javax.xml.transform.TransformerException
        Converts 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 expression
        xmlResp - the XML string
        Returns:
        an instance of StringValue
        Throws:
        com.smartgridready.driver.api.common.GenDriverException - when an error occurred during parsing