O'Reilly logo

Umbraco User's Guide by Paul Sterling, Nik Wahlberg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

UNDERSTANDING XPATH

XPath, or XML Path Language, is one of those things that takes a while to grasp, at least for most developers. It's been compared to regular expressions, which in my opinion is a bit much because it's not nearly that complicated. XPath is a query language for selecting nodes from an XML document source. In the Umbraco scenario, you use XPath as part of the XSLT to target nodes from the umbraco.config (XML cache) mentioned earlier in this chapter. In a nutshell, XPath allows you to traverse any node structure by providing a set of steps that make up a path, or more complex instructions to programmatically manipulate the output from the source XML. To illustrate the concept, before you dig into the practicals of using XPath in Umbraco, take a look at Listing 11-1 as a basis for the following XPath examples. This is an abbreviation of the classic book.xml example that you see in most XSL/XPath examples on the Internet.

LISTING 11-1: books.xml

image
<?xml version=“1.0”?> <catalog> <book id=“bk101”> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> <description>An in-depth look at creating applications with XML.</description> </book> <book id=“bk102”> <author>Ralls, Kim</author> <title>Midnight Rain</title> <genre>Fantasy</genre> <price>5.95</price> <publish_date>2000-12-16</publish_date> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required