Introduction to XPath

XPath is an XML-based language for locating parts of an XML document, such as elements and attributes. Suppose that you want to use an application, such as an XSLT processor, to transform the contents of all the NAME elements in an XML document into HTML. In this case, you need XPath to locate the NAME elements in the XML document.

To locate the parts of an XML document, XPath models an XML document as a document tree that contains nodes. The nodes represent the contents of the XML document. For example, the graphic displays a document tree that contains the nodes for the following code snippet:

  <Messages>
    <mail>
      <to> abc@example.com </to>
      <from> xyz@example.com </from>
      <body> Hello! How are you? </body>
    </mail>
  </Messages>

The graphic shows a document tree that contains nodes.
Click the Next button to continue.