XML Server Getting Started
/**
* Use an XPath string to select a single node.
* XPath namespace prefixes are resolved from the namespaceNode.
*
* @param contextNode The node to start searching from.
* @param str A valid XPath string.
* @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces.
* @return The first node found that matches the XPath, or null.
*/
public Node selectSingleNode(Node contextNode, String str, Node namespaceNode)
throws SAXException
{
// Have the XObject return its result as a NodeSet.
NodeList nl = selectNodeList(contextNode, str, namespaceNode);
// Return the first node, or null
return (nl.getLength() > 0) ? nl.item(0) : null;
}
/**
* Use an XPath string to select a nodelist.
* XPath namespace prefixes are resolved from the context Node.
*
* @param contextNode The node to start searching from.
* @param str A valid XPath string.
* @return A nodelist, should never be null.
*/
public NodeList selectNodeList(Node contextNode, String str)
throws SAXException
{
return selectNodeList(contextNode, str, contextNode);
}
/**
* Use an XPath string to select a nodelist.
* XPath namespace prefixes are resolved from the namespaceNode.
*
* @param contextNode The node to start searching from.
* @param str A valid XPath string.
* @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces.
* @return A nodelist, should never be null.
*/
public NodeList selectNodeList(Node contextNode, String str, Node namespaceNode)
throws SAXException
{
// Execute the XPath, and have it return the result
XObject list = executeXPath(contextNode, str, namespaceNode);
// Have the XObject return its result as a NodeSet.
return list.nodeset();
}
2000 2002 Computer Technology Inc. All rights reserved.
Page 66
J2EE Web Hosting Tundra XML Server Pages J2EE Hosting
|
|
|
|
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved. |