Class XmlObject


  • public class XmlObject
    extends java.lang.Object
    A helper object for evaluating Json content by utilizing XPath expressions.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static XmlObject createFrom​(java.io.InputStream in)
      Parses XML content from the input stream and creates new XML object
      static XmlObject createFrom​(java.lang.String xml)
      Parses XML content and creates new XML object
      boolean exists​(java.lang.String path)
      Checks whether the specified xpath exists in this XML object.
      java.lang.String get​(java.lang.String path)
      Looks up a value in the parsed XML
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • createFrom

        public static XmlObject createFrom​(java.io.InputStream in)
        Parses XML content from the input stream and creates new XML object
        Parameters:
        in - an input stream containing XML
        Returns:
        an object for evaluating structure of the parsed content
        Throws:
        java.lang.IllegalArgumentException - if the input stream fails to read or does not contain a well formed XML
      • createFrom

        public static XmlObject createFrom​(java.lang.String xml)
        Parses XML content and creates new XML object
        Parameters:
        xml - an XML content to parse
        Returns:
        an object for evaluating structure of the parsed content
        Throws:
        java.lang.IllegalArgumentException - if the content does not contain a well formed XML
      • get

        public java.lang.String get​(java.lang.String path)
        Looks up a value in the parsed XML
        Parameters:
        path - a XML path, e.g. //product/code, pointing to the element whose value needs to be retrieved.
        Returns:
        value of the element matching the path location.
      • exists

        public boolean exists​(java.lang.String path)
        Checks whether the specified xpath exists in this XML object.
        Parameters:
        path - an xPath, e.g. //product/code to be verified
        Returns:
        true, if the specified path exists in this XML object;
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object