org.merlotxml.util.xml
Class XPathUtil
java.lang.Object
org.merlotxml.util.xml.XPathUtil
- public class XPathUtil
- extends java.lang.Object
General XPath utilities
- Author:
- Tim McCune (with thanks to Scott Boag for providing the initial example)
Method Summary |
static org.apache.xpath.objects.XObject |
eval(org.w3c.dom.Node contextNode,
java.lang.String str)
|
static org.w3c.dom.Element |
getNodeById(org.w3c.dom.Node context,
java.lang.String id)
|
static java.lang.String |
getValue(org.w3c.dom.Node contextNode,
java.lang.String str)
|
static java.util.List |
getValueList(org.w3c.dom.Node contextNode,
java.lang.String xpath)
|
static java.lang.String |
nodeToString(org.w3c.dom.Node node)
|
static java.lang.String |
parseVariable(org.w3c.dom.Node contextNode,
java.lang.String xPathString)
|
static org.w3c.dom.NodeList |
selectNodes(org.w3c.dom.Node contextNode,
java.lang.String str)
Select a list of nodes using an XPath expression |
static org.w3c.dom.Node |
selectSingleNode(org.w3c.dom.Node contextNode,
java.lang.String str)
Select a single node using an XPath expression |
static java.lang.String |
selectString(org.w3c.dom.Node contextNode,
java.lang.String str)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XPathUtil
public XPathUtil()
selectNodes
public static org.w3c.dom.NodeList selectNodes(org.w3c.dom.Node contextNode,
java.lang.String str)
throws org.xml.sax.SAXException
- Select a list of nodes using an XPath expression
- Parameters:
contextNode
- The node to start searching from.str
- A valid XPath string.
- Returns:
- The list of nodes that match the XPath, or null if none
- Throws:
org.xml.sax.SAXException
selectSingleNode
public static org.w3c.dom.Node selectSingleNode(org.w3c.dom.Node contextNode,
java.lang.String str)
throws org.xml.sax.SAXException
- Select a single node using an XPath expression
- Parameters:
contextNode
- The node to start searching from.str
- A valid XPath string.
- Returns:
- The first node found that matches the XPath, or null if none
- Throws:
org.xml.sax.SAXException
getValue
public static java.lang.String getValue(org.w3c.dom.Node contextNode,
java.lang.String str)
throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
getValueList
public static java.util.List getValueList(org.w3c.dom.Node contextNode,
java.lang.String xpath)
throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
parseVariable
public static java.lang.String parseVariable(org.w3c.dom.Node contextNode,
java.lang.String xPathString)
eval
public static org.apache.xpath.objects.XObject eval(org.w3c.dom.Node contextNode,
java.lang.String str)
selectString
public static java.lang.String selectString(org.w3c.dom.Node contextNode,
java.lang.String str)
throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
getNodeById
public static org.w3c.dom.Element getNodeById(org.w3c.dom.Node context,
java.lang.String id)
nodeToString
public static java.lang.String nodeToString(org.w3c.dom.Node node)