Chapter 1. Essential XPath
IN THIS CHAPTER
The main purpose of XPath is to make it easy to work with the data in an XML document. XPath lets you address specific parts of XML documents.
Let's begin with an example to demonstrate the reason to use XPath. Say, for example, that you have an XML document,
ch01_01.xml, that stores information about various planets in three
<planet> elements, as you see in Listing 1.1.
Example 1.1. A Sample XML Document (
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="ch01_02.xsl"?> <planets> <planet> <name>Mercury</name> ...