| |
[XSLT Reference] [XPath Reference]
[ Download this Reference]
XPath ReferenceGeneral introAn XPath expression contains one or more "location steps", separated by slashes. Each location step has
the following form: axis-name :: node-test [predicate]*Or in English: an axis name, then two colons, then a node-test and finally zero or more predicates in brackets.
We will show a list of valid axes and a list of valid node-sets in this appendix. A predicate is an expression. It exists of
values, operators and other XPath expressions. The XPath axis contains a part of the document, defined from the perspective of the "context node". The node
test makes a selection from the nodes on that axis. By adding predicates, it is possible to select a subset from these nodes.
If the expression in the predicate returns true, the node remains in the selected set, otherwise it is removed. XPath defines a set of functions for use in predicates. These are listed in the appendix as well. - W3C 1.0 specification (recommendation)
- Go there
- MSXML 2.0 (IE5)
- MSXML 2.6 (January 2000 preview)
- MSXML 3.0
- Go there
- MSXML 4.0
- Go there
- XML classes in .NET Framework class library
- Go there
|
| Contains all direct children of the context node (that is the children, but not any of the children's children) | (default axis) | element |
X
|
X
|
X
|
X
|
X
|
X
| | Contains the direct parent node (and only the direct parent node) of the context node. | .. | element |
X
|
X
|
X
|
X
|
X
|
X
| | All children of the context node, including all children's children recursively | // | element |
X
|
X
|
X
|
X
|
X
|
X
| | Contains the context node's parent node, its parent's parent node etc., all the way up to the document root. If the context node is the root node, the ancestor node is empty. | | element |
X
| |
X
|
X
|
X
|
X
| | Contains all attributes on the context node. The axis will be empty unless the context node is an element. | @ | attribute |
X
| |
X
|
X
|
X
|
X
| | Identical to the ancestor axis, but including the context node itself. | | element |
X
| |
X
|
X
|
X
|
X
| | Identical to the descendant axis, but including the context node itself. | | element |
X
| |
X
|
X
|
X
|
X
| | Contains only the context node itself. | . | element |
X
|
X
|
X
|
X
|
X
|
X
| | Contains all siblings (children of the same parent node) of the context node that come before the context node in document order | | element |
X
| | |
X
|
X
|
X
| | Contains all siblings (children of the same parent node) of the context node that come after the context node in document order | | element |
X
| | |
X
|
X
|
X
| | Contains all namespaces available on the context node. This includes the default namespace and the xml namespace (these are automatically declared in any document). The axis will be empty unless the context node is an element. | | namespace |
X
| | |
X
|
X
|
X
| | Contains all nodes that come after the context node in the document order. This means that the start tag of the node must come after the closing tag of the context node and therefore excludes the descendants of the context node. | | element |
X
| | |
X
|
X
|
X
| | Contains all nodes that come before the context node in the document order. This includes all elements that are already closed (their closing tag comes before the context node in the document) and therefore excludes all ancestors of the context node. | | element |
X
| | |
X
|
X
|
X
|
|
| Returns true for all nodes of the primary type of the axis. |
X
|
X
|
X
|
X
|
X
|
X
| | Returns true for all comment nodes |
X
|
X
|
X
|
X
|
X
|
X
| | Returns true for all nodes of that name. If the node test is 'PERSON', it returns true for all nodes of name 'PERSON' |
X
|
X
|
X
|
X
|
X
|
X
| | Returns true for all nodes, except attributes and namespaces |
X
|
X
|
X
|
X
|
X
|
X
| | Returns true for all processing instruction nodes. If a name is passed,
returns true only for processing instruction nodes of that name |
X
|
X
|
X
|
X
|
X
|
X
| | Returns true for all text nodes |
X
|
X
|
X
|
X
|
X
|
X
|
|
|
X
| |
X
|
X
|
X
|
X
| |
X
| | |
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| | |
X
|
X
|
X
| |
X
|
X
|
X
|
X
|
X
|
X
| |
X
| | |
X
|
X
|
X
| |
X
|
X
|
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| | |
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| | |
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
| |
X
| |
X
|
X
|
X
|
X
|
Select all descending elements from the root /descendant::*Select ancestor elements of the context node that are named 'Chapter' ancestor::ChapterSelect nodes that have more than two direct children of name 'Skip' /descendant::node()[count(child::Skip) > 2]Select all Student elements whose name attribute start with an A (using shorthand notation) //Student[starts-with(@name, 'A')]
Note: You can now download the full content of the XPath reference, the XSLT reference and the
DOM reference in one PDF document. This document contains the implementation tables, internal
links to navigate through the references, a full linked table of contents. You can use free text
search through the whole reference or print as a nicely formatted document.
Download here...
© 2000 Teun Duynstee. Shown on TopXML.com. Information used from XSLT and
XPath recommendations © W3C and MSDN documentation © Microsoft.
Do you have comments, additions or suggestions, mail me.
|
|