ru.sstu.xml
Class XPathUtil

java.lang.Object
  extended by ru.sstu.xml.XPathUtil

public final class XPathUtil
extends Object

XPathUtil class is utility class for XPath Expressions.

Since:
XML 1.0
Author:
Denis Murashev

Method Summary
static boolean exists(Node context, String xPath)
          Checks if given XPath exists in given context.
static Element getElement(Node context, String xPath)
          Search for element for given XPath in given context.
static Element[] getElements(Node context, String xPath)
          Search for elements for given XPath in given context.
static Node getNode(Node context, String xPath)
          Search for node for given XPath in given context.
static Node[] getNodes(Node context, String xPath)
          Search for nodes for given XPath in given context.
static Number getNumber(Node context, String xPath)
          Search for number for given XPath in given context.
static String getText(Node context, String xPath)
          Search for text for given XPath in given context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getElement

public static Element getElement(Node context,
                                 String xPath)
                          throws XmlException
Search for element for given XPath in given context.

Parameters:
context - context Node
xPath - XPath expression
Returns:
Element found
Throws:
XmlException - if some error occurs

getNode

public static Node getNode(Node context,
                           String xPath)
                    throws XmlException
Search for node for given XPath in given context.

Parameters:
context - context Node
xPath - XPath expression
Returns:
Node found
Throws:
XmlException - if some error occurs

getElements

public static Element[] getElements(Node context,
                                    String xPath)
                             throws XmlException
Search for elements for given XPath in given context.

Parameters:
context - context Node
xPath - XPath expression
Returns:
array of Elements found
Throws:
XmlException - if some error occurs

getNodes

public static Node[] getNodes(Node context,
                              String xPath)
                       throws XmlException
Search for nodes for given XPath in given context.

Parameters:
context - context Node
xPath - XPath expression
Returns:
array of Nodes found
Throws:
XmlException - if some error occurs

getText

public static String getText(Node context,
                             String xPath)
                      throws XmlException
Search for text for given XPath in given context.

Parameters:
context - context Node
xPath - XPath expression
Returns:
text found
Throws:
XmlException - if some error occurs

getNumber

public static Number getNumber(Node context,
                               String xPath)
                        throws XmlException
Search for number for given XPath in given context.

Parameters:
context - context Node
xPath - XPath expression
Returns:
number found
Throws:
XmlException - if some error occurs

exists

public static boolean exists(Node context,
                             String xPath)
                      throws XmlException
Checks if given XPath exists in given context.

Parameters:
context - context Node
xPath - XPath expression
Returns:
true if XPath exists
Throws:
XmlException - if some error occurs


Copyright © 2011 TFI branch of Engels Instutute of Technology. All Rights Reserved.