<s1 title="XPath find()">

<p>XPath is a language for selecting XML nodes.  It was originally part of the
XSLT spec, but was split out because the W3C realized XPath was useful
by itself.</p>

<p>In Resin, you can use <var/XPath.find()/> to find a node from an XML DOM
data structure.</p>

<def>
XPath.find(String pattern, Node node)
</def>

<p>The first example finds the first &lt;b> in the tree.</p>

<example title='test.xml'>
&lt;top>
  &lt;a id='1'>
    &lt;b id='2'/>
  &lt;/a>
  &lt;b id='3'/>
  &lt;c id='4'/>
&lt;/top>
</example>

<example>
import org.w3c.dom.*;
import com.caucho.xml.*;
import com.caucho.xpath.*;

...

Document doc = new Xml().parseDocument("test.xml");

Element elt = (Element) XPath.find("b", doc);

System.out.println("Node: " + elt.getNodeName());
System.out.println("id: " + elt.getAttribute("id"));
</example>
<results>
Node: b
id: 2
</results>

<s2 title="Summary">

<ul>
<li><var/XPath/> is a language for selecting XML nodes
<li><var/XPath.find()/> returns the first matching node
<li>XPath searches in <var/document order/>
<li>The pattern <var/b/> matches any element <var/&lt;b>/>
</ul>

</s2>
</s1>
