This tutorial introduces and covers most aspects of the XML Path Language, or XPath. It is aimed at people who do not know XPath or want a refresher. If you plan to use XSLT, you should take this tutorial first. You will learn:
- What XPath is
- The syntax and semantics of the XPath language
- How to use XPath location paths
- How to use XPath expressions
- How to use XPath functions
- How XPath relates to XSLT
XPath is a W3C standard. This tutorial focuses on version 1.0. Refer to Tutorial wrap-up for information on the upcoming XPath 2.0.
This tutorial assumes basic knowledge of XML. For example, you should know what elements, attributes, and values are. If you aren't familiar with these, I recommend you first take the "Introduction to XML" tutorial, listed in Resources.
You will also need a text editor and a Web browser. Although it's not a prerequisite, you may also find it useful to have an XML editor, as it will include an XPath evaluator that allows you to test the XPath expressions used here.
Listed below are the technologies mentioned in this tutorial. Skip this if you are already familiar with XML-related technologies. All of these technologies are W3C specifications.
- XML is the eXtensible Markup Language. It is the basis for the other technologies listed below (and many more), and is very widely used in the industry because of its extensibility.
- XML Schema, sometimes referred to as XSD, defines the rules for the data contained in XML documents.
- XSL (eXtensible Stylesheet Language) and XSLT (XSL transformations) are used to present XML documents in a different format -- for example, HTML.
- XPath -- hmm... that's a good question. ;-)