diff options
Diffstat (limited to 'files/zh-cn/web/xpath')
-rw-r--r-- | files/zh-cn/web/xpath/axes/index.html | 71 | ||||
-rw-r--r-- | files/zh-cn/web/xpath/index.html | 62 |
2 files changed, 133 insertions, 0 deletions
diff --git a/files/zh-cn/web/xpath/axes/index.html b/files/zh-cn/web/xpath/axes/index.html new file mode 100644 index 0000000000..d2254b85fa --- /dev/null +++ b/files/zh-cn/web/xpath/axes/index.html @@ -0,0 +1,71 @@ +--- +title: Axes +slug: Web/XPath/Axes +tags: + - XPath + - XPath_Reference +translation_of: Web/XPath/Axes +--- +<p>{{ XsltRef() }} There are thirteen different axes in the <a href="cn/XPath">XPath</a> specification. An axis represents a relationship to the context node, and is used to locate nodes relative to that node on the tree. The following is an extremely brief description of the thirteen available axes and the degree of support available in <a href="cn/Gecko">Gecko</a>.</p> +<p>For further information on using XPath expressions, please see the <a href="cn/Transforming_XML_with_XSLT/For_Further_Reading">For Further Reading</a> section at the end of <a href="cn/Transforming_XML_with_XSLT">Transforming XML with XSLT</a> document.</p> +<p> </p> +<dl> + <dt> + <a href="cn/XPath/Axes/ancestor">ancestor</a></dt> + <dd> + Indicates all the ancestors of the context node beginning with the parent node and traveling through to the root node.</dd> + <dt> + <a href="cn/XPath/Axes/ancestor-or-self">ancestor-or-self</a></dt> + <dd> + Indicates the context node and all of its ancestors, including the root node.</dd> + <dt> + <a href="cn/XPath/Axes/attribute">attribute</a></dt> + <dd> + Indicates the attributes of the context node. Only elements have attributes. This axis can be abbreviated with the at sign (<code>@</code>).</dd> + <dt> + <a href="cn/XPath/Axes/child">child</a></dt> + <dd> + Indicates the children of the context node. If an XPath expression does not specify an axis, is understood by default. Since only the root node or element nodes have children, any other use will select nothing.</dd> + <dt> + <a href="cn/XPath/Axes/descendant">descendant</a></dt> + <dd> + Indicates all of the children of the context node, and all of their children, and so forth. Attribute and namespace nodes are <b>not</b> included - the <code>parent</code> of an <code>attribute</code> node is an element node, but <code>attribute</code> nodes are not the children of their parents.</dd> + <dt> + <a href="cn/XPath/Axes/descendant-or-self">descendant-or-self</a></dt> + <dd> + Indicates the context node and all of its descendants. Attribute and namespace nodes are <b>not</b> included - the <code>parent</code> of an <code>attribute</code> node is an element node, but <code>attribute</code> nodes are not the children of their parents.</dd> + <dt> + <a href="cn/XPath/Axes/following">following</a></dt> + <dd> + Indicates all the nodes that appear after the context node, except any <code>descendant</code>, <code>attribute</code>, and <code>namespace</code> nodes.</dd> + <dt> + <a href="cn/XPath/Axes/following-sibling">following-sibling</a></dt> + <dd> + Indicates all the nodes that have the same parent as the context node and appear after the context node in the source document.</dd> + <dt> + <a href="cn/XPath/Axes/namespace">namespace</a> + <i> + (not supported)</i> + </dt> + <dd> + Indicates all the nodes that are in scope for the context node. In this case, the context node must be an element node.</dd> + <dt> + <a href="cn/XPath/Axes/parent">parent</a></dt> + <dd> + Indicates the single node that is the parent of the context node. It can be abbreviated as two periods (<code>..</code>).</dd> + <dt> + <a href="cn/XPath/Axes/preceding">preceding</a></dt> + <dd> + Indicates all the nodes that precede the context node in the document except any <code>ancestor</code>, <code>attribute</code> and <code>namespace</code> nodes.</dd> + <dt> + <a href="cn/XPath/Axes/preceding-sibling">preceding-sibling</a></dt> + <dd> + Indicates all the nodes that have the same parent as the context node and appear before the context node in the source document.</dd> + <dt> + <a href="cn/XPath/Axes/self">self</a></dt> + <dd> + Indicates the context node itself. It can be abbreviated as a single period (<code>.</code>).</dd> +</dl> +<div class="noinclude"> + </div> +<p>{{ languages( { "es": "es/XPath/Ejes", "fr": "fr/XPath/Axes", "ja": "ja/XPath/Axes", "en": "en/XPath/Axes", "pl": "pl/XPath/Osie" } ) }}</p> diff --git a/files/zh-cn/web/xpath/index.html b/files/zh-cn/web/xpath/index.html new file mode 100644 index 0000000000..5905c3209f --- /dev/null +++ b/files/zh-cn/web/xpath/index.html @@ -0,0 +1,62 @@ +--- +title: XPath +slug: Web/XPath +tags: + - XPath +translation_of: Web/XPath +--- +<p><span class="seoSummary">XPath 的意思是 XML 路径语言。它使用的一个非 XML 语法提供一种灵活地定位 <a href="/zh-CN/docs/XML" title="XML">XML</a> 文档的不同部分的方法。它同时也可以用于检测文档中某个节点是否与某个模式(pattern)匹配。</span></p> + +<p>XPath 主要被用于 <a href="/zh-CN/docs/XSLT" title="XSLT">XSLT</a>,也可用于定位文档元素,像类 XML 语言文档(如HTML 和 <a href="/zh-CN/docs/XUL" title="XUL">XUL</a> ) 通过 <a href="/zh-CN/docs/DOM" title="DOM">DOM</a> 定位元素一样。替代 {{Domxref("document.getElementById")}} 方法、 {{Domxref("element.childNodes")}} 属性和其他DOM核心特性。</p> + +<p>XPath 使用路径标识符通过层级结构来导航XML文档。它使用非XML语法,以致于它可以被用在URIs和XML属性值上。</p> + +<div class="note"> +<p><strong>注意:</strong>XPath 的浏览器支持差别很大;Firefox 支持地相当不错 (尽管没有计划进一步提高支持),而其他浏览器则较小程度地实现了它。如果你需要一个兼容主流浏览器的 XPath,你可以考虑试试 <a href="http://nchc.dl.sourceforge.net/project/js-xpath/js-xpath/1.0.0/xpath.js">js-xpath</a> 或 <a href="https://github.com/google/wicked-good-xpath">wicked-good-xpath</a>.</p> +</div> + +<div class="row topicpage-table"> +<div class="section"> +<h2 class="Documentation" id="Documentation" name="Documentation">文档</h2> + + <dl> + <dt><a href="/zh-CN/docs/Introduction_to_using_XPath_in_JavaScript" title="Introduction_to_using_XPath_in_JavaScript">在 JavaScript 中使用 XPath 的介绍</a></dt> + <dd>描述了 XPath 的一个非 XSLT 使用。</dd> + <dt><a href="/en-US/docs/XPath/Axes" title="XPath/Axes">XPath:Axes</a></dt> + <dd>List and definition of the axes defined in the XPath specification. Axes are used to describe the relationships between nodes.</dd> + <dt><a href="/en-US/docs/XPath/Functions" title="XPath/Functions">XPath:Functions</a></dt> + <dd>List and description of the core XPath functions and XSLT-specific additions to XPath.</dd> + <dt><a href="/en-US/docs/Transforming_XML_with_XSLT" title="Transforming_XML_with_XSLT">Transforming XML with XSLT</a></dt> + <dd>XSLT uses XPath to address code segments in a XML document that it wishes to transform.</dd> + <dt><a href="/en-US/docs/Web/XPath/Snippets" title="Using_XPath">XPath snippets</a></dt> + <dd>JavaScript utility functions to use in your own code, based on <a class="external external-icon" href="http://www.w3.org/TR/DOM-Level-3-XPath/">DOM Level 3 XPath </a>APIs.</dd> + <dt><a class="external" href="http://www.xml.com/pub/a/2000/08/holman/">What is XSLT?</a></dt> + <dd>This extensive introduction to XSLT and XPath assumes no prior knowledge of the technologies, and guides the reader through background, context, structure, concepts and introductory terminology.</dd> + <dt><a href="/en-US/docs/JXON" title="/en-US/docs/JXON">JXON</a></dt> + <dd><strong>JXON</strong> (lossless <strong>J</strong>avaScript <strong>X</strong>ML <strong>O</strong>bject <strong>N</strong>otation) is a generic name by which is defined the representation of JavaScript Objects using <a href="/en/XML" title="en/XML">XML</a>. There are some cases in which the whole content of an XML document must be read from the JavaScript interpreter (like for web-apps languages or settings XML documents, for example). In these cases JXON could represent the most practical way and a valid alternative to XPath.</dd> + </dl> + +<p><span class="alllinks"><a href="/en-US/docs/tag/XPath" title="tag/XPath">View All...</a></span></p> +</div> + +<div class="section"> +<h2 class="Tools" id="Tools" name="Tools">工具</h2> + +<dl> + <dt><a class="link-https" href="https://addons.mozilla.org/zh-CN/firefox/addon/1192">XPather</a></dt> + <dd>Feature rich XPath generator, editor, inspector, and simple extraction tool (FireFox Add-On).</dd> + <dt><a class="link-https" href="https://addons.mozilla.org/zh-CN/firefox/addon/11900" title="https://addons.mozilla.org/zh-CN/firefox/addon/11900">FireXPath</a></dt> + <dd>XPath panel that integrates tightly into FireBug, providing an editor and inspector (FireFox Add-On).</dd> + <dt><a class="external" href="http://qutoric.com/xmlquire/">XMLQuire (formerly known as SketchPath)</a></dt> + <dd>A Graphical XPath Builder/Debugger(.NET).</dd> +</dl> + +<h2 class="Related_Topics" id="Related_Topics" name="Related_Topics">相关主题</h2> + +<ul> + <li><a href="/zh-CN/docs/XSLT" title="XSLT">XSLT</a>, <a href="/zh-CN/docs/XQuery" title="XQuery">XQuery</a>, <a href="/zh-CN/docs/XML" title="XML">XML</a>, <a href="/zh-CN/docs/DOM" title="DOM">DOM</a>, <a href="/zh-CN/docs/JXON" title="/zh-CN/docs/JXON">JXON</a>, <a href="/zh-CN/docs/JSON/JSONPath" title="JSON/JSONPath">JSONPath</a></li> +</ul> +</div> +</div> + +<div>{{QuickLinksWithSubpages("/zh-CN/docs/Web/XPath")}}</div> |