One of the fundamental constructs for XSL transformations and XML links, XPath is nonetheless one of the lesser lights of the XML universe. However, if you're serious about developing your XML skills, you need to know it inside out - and this tutorial has all you need to get started.
Given this basic structure, XPath now makes it possible to locate a node, or set of nodes, at any level of the tree, using a thingamajig known as a "location path."
A location path may be either an absolute path, which expresses a location with reference to the root node, or a relative path, which expresses a location with reference to the current node (since this location is always in context to something else, it is also referred to as the "context node"). Location paths are made up of a series of "location steps", each identifying one level in the XPath tree and separated from each other by a forward slash (/).
A location step can be further broken down into three components: there's an "axis", which defines the relationship to use when selecting nodes; a "node test", which specifies the types of nodes to select; and optional "predicates" to filter out unwanted nodes from the resulting collection (I'll explain each of these in detail further down so that they become a little less frightening.)
The syntax of a location step is as follows
axis::node-test[predicates]
This article copyright Melonfire 2001. All rights reserved.