org.littleshoot.util.xml
Class XPathUtils

java.lang.Object
  extended by org.littleshoot.util.xml.XPathUtils

public class XPathUtils
extends Object

Implementation of XPath utilities.


Method Summary
 int getInt(String xPath)
           
 Node getNode(String xPath)
           
 NodeList getNodes(String xPath)
           
 String getString(String xPath)
           
 Collection<String> getStrings(String xPath)
           
 URL getUrl(String xPath)
           
static XPathUtils newXPath(Document doc)
          Creates a new XPathUtils instance.
static XPathUtils newXPath(InputStream is)
          Creates a new XPathUtils instance.
static XPathUtils newXPath(String str)
          Creates a new XPathUtils instance.
static XPathUtils newXPath(URL url)
          Creates a new XPathUtils instance from the data at the specified HTTP url.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newXPath

public static XPathUtils newXPath(URL url)
Creates a new XPathUtils instance from the data at the specified HTTP url.

Parameters:
url - The URL to load XML data from.
Returns:
An XPathUtils instance for the data at the given URL.

newXPath

public static XPathUtils newXPath(String str)
                           throws SAXException,
                                  IOException
Creates a new XPathUtils instance.

Parameters:
str - The string with XML data.
Returns:
A new XPathUtils instance.
Throws:
SAXException - If there's a SAX error in the XML.
IOException - If there's an IO error reading the stream.

newXPath

public static XPathUtils newXPath(InputStream is)
                           throws SAXException,
                                  IOException
Creates a new XPathUtils instance.

Parameters:
is - The InputStream with XML data.
Returns:
A new XPathUtils instance.
Throws:
SAXException - If there's a SAX error in the XML.
IOException - If there's an IO error reading the stream.

newXPath

public static XPathUtils newXPath(Document doc)
Creates a new XPathUtils instance.

Parameters:
doc - The XML data.
Returns:
A new XPathUtils instance.

getInt

public int getInt(String xPath)
           throws XPathExpressionException
Throws:
XPathExpressionException

getString

public String getString(String xPath)
                 throws XPathExpressionException
Throws:
XPathExpressionException

getNodes

public NodeList getNodes(String xPath)
                  throws XPathExpressionException
Throws:
XPathExpressionException

getStrings

public Collection<String> getStrings(String xPath)
                              throws XPathExpressionException
Throws:
XPathExpressionException

getUrl

public URL getUrl(String xPath)
           throws MalformedURLException,
                  XPathExpressionException
Throws:
MalformedURLException
XPathExpressionException

getNode

public Node getNode(String xPath)
             throws XPathExpressionException
Throws:
XPathExpressionException


Copyright © 2011-2013 LittleShoot. All Rights Reserved.