O'Reilly logo

Sams Teach Yourself XML in 10 Minutes by Andrew H. Watt

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

XPath Functions

XPath provides a function library that can manipulate or return four data types—node-sets, Boolean values, strings, and numbers. This section briefly looks at how two of those functions can be used.

The position() Function

The position() function is widely used. Suppose that you have an XML document similar to the following:

<book> 
<title>Sams Teach Yourself XML in 10 Minutes</title> 
<chapter number="1" title="What is XML?"> 
<!-- The text of Chapter 1 could go here --> 
</chapter> 
<chapter number="2" title="The Structure of an XML document"> 
<!-- The text of Chapter 2 could go here --> 
</chapter> 
<!-- Other <chapter> elements and their content would go 
  here --> 
</book> 

You might want to select the chapter element node that ...

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