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.
It's strange but true - even if you've been working with XML for a while, it's quite likely that you've never heard of XPath prior to today. And even if you have, it's probably been in the context of another technology - XSLT or XPointer - with your experience with XPath itself limited to a cursory examination.
Now, that's a shame, because XPath is not only pretty interesting, but it forms an important component of both XML stylesheet tranformations (XSLT) and the XPointer linking language. By providing XML developers with a standard method of addressing any part of an XML document, XPath is a small yet very important piece of the whole XML jigsaw. XSLT uses it extensively to match nodes in an XML source tree, while XPointer uses it in combination with XLink to identify specific locations in an XML document.
My point? Very simple - if you're at all serious about XML, you need to understand XPath. And over the course of this tutorial, I'm going to assist you in this endeavour by explaining the fundamentals of the XPath data model, together with some examples of XPath's more complex expressions and functions.
Before we get going, though, a few disclaimers:
First, I don't claim to be an expert on XPath. Much of the material in this tutorial is based on my own experience as a developer, or gleaned from late-night email conversations over beer and stale pizza. In other words - caveat emptor!
Second, as new XML standards are proposed and disposed, the material here may become invalid; you should always refer to the most current standard or recommendation for up-to-date information (links to everything you need are included at the end of the article.) This tutorial is based on the W3C's XPath 1.0 recommendation.
Now that I have that off my chest - let's get started!
This article copyright Melonfire 2001. All rights reserved.