xpath-find.xtp

来自「resinweb服务器源文件」· XTP 代码 · 共 56 行

XTP
56
字号
<s1 title="XPath find()"><p>XPath is a language for selecting XML nodes.  It was originally part of theXSLT spec, but was split out because the W3C realized XPath was usefulby itself.</p><p>In Resin, you can use <var/XPath.find()/> to find a node from an XML DOMdata 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: bid: 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>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?