⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xpath-select.xtp

📁 resinweb服务器源文件
💻 XTP
字号:
<s1 title="XPath select()"><p>Finding a node is useful but often you will want to select all nodesmatching a pattern.  For example, a web spider will want to select all linksin a HTML page.</p><p>The <var/select()/> call returns an Iterator letting you look at allthe nodes.  The Iterator returns nodes in document order.</p><p>You can precompile XPath patterns and then reuse the precompiled patternover again.  The <var/XPath.find()/> call in the previous page used aconvenient, but inefficient call to find the node.  In this example, we'llprecompile the pattern before using the select.</p><p>The following example reads the home page of http://localhost:8080 andand returns all the &lt;a href> links in that page.</p><example title="Spidering a Web Page">Pattern pattern = XPath.parseMatch("a[@href]");Document doc = new Html().parseDocument("http://localhost:8080");Iterator iter = pattern.select(doc);while (iter.hasNext()) {  Element elt = (Element) iter.next();  System.out.println("link: " + elt.getAttribute("href"));}</example><results>link: /index.xtplink: /ref/faq.xtplink: /ref/index.xtplink: /javadoc/index.html...</results><s2 title="Summary"><ul><li>Precompiling <var/XPath/> patterns is more efficient<li><var/XPath.select()/> can "spider" web pages<li>select returns nodes in <var/document order/><li>The pattern <var/a[@href]/> returns <var/&lt;a>/> elementswith an <var/href/> attribute.</ul></s2></s1>

⌨️ 快捷键说明

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