XPath Introduction XPath Introduction

Home > XML Tutorials > An Introduction to XPath

Learning XPath by Example

XPath (XML Path Language) is a language for selecting nodes from within an XML document.

This tutorial explains various common XPath expressions used to extract data from XML documents.

Version 1.0 of the XPath standard was released in 1999, and is now supported in most languages and platforms.

Version 2.0 of the standard was released in 2007 in an effort to share more functionality between the XSLT and XQuery standards. Version 2.0 is backwardly compatible with 1.0 and adds a number new operators including looping, set manipulation, conditional expression, and aggregate functions.

XPath Examples

The XPath Expression Builder included in Liquid XML Studio makes it simple to visualize the results of your XPath Expressions.

Sample XML Data

<?xml version="1.0" encoding="utf-8" ?>
        <Album artist="The Last Shadow Puppets" title="The Age Of The Understatement">
                <Track rating="4" length="P3M7S">The Age Of The Understatement</Track>
                <Track rating="3" length="P2M18S">Standing Next To Me</Track>
                <Track rating="5" length="P2M26S">Calm Like You</Track>
                <Track rating="3" length="P3M38S">Separate and Ever Deadly</Track>
                <Track rating="2" length="P2M37S">The Chamber</Track>
                <Track rating="3" length="P2M44S">Only The Truth</Track>
        <Album artist="Kings Of Leon" title="Because Of The Times">
                <Track rating="4" length="P7M10S">Knocked Up</Track>
                <Track rating="2" length="P2M57S">Charmer</Track>
                <Track rating="3" length="P3M21S">On Call</Track>
                <Track rating="4" length="P3M09S">McFearless</Track>
                <Track rating="1" length="P3M59S">Black Thumbnail</Track>

Example XPath Expressions

XPath Expression Results
Select all the albums:
Select the artist attribute for all albums:
Select all the tracks in all albums:
Select all albums by the Kings Of Leon:
/Catalog/Album[@artist="Kings Of Leon"]
Select all tracks in all albums by the Kings Of Leon:
/Catalog/Album[@artist="Kings Of Leon"]/Track
Select the second album:
Selects all tracks with a rating greater than '2':
Selects the text for all the tracks:

Video Tutorials

VIEW TUTORIAL XML Schema Editor Overview

XML Schema Editor Overview

This video overview shows how to work in the graphical, text and split views, adding items, changing properties and updating documentation annotations.

VIEW TUTORIAL Generate a Sample XML Document

Generate a Sample XML Document

This video tutorial shows you how to create a sample XML document from an industry standard schema (Google Site Map).

VIEW TUTORIAL Generate HTML Documentation

Generate HTML Documentation

This video tutorial shows how to create HTML documentation for an XML Schema.


XML Data Binding

This video tutorial shows you how to generate strongly typed API source code from your XSD using the Liquid XML Data Binder.


XML Data Mapper

This video tutorial shows how to create a mapping transform, using the graphical drag and drop interface, to convert XML data of different XML Schema.

Make working with XSD easy using Liquid XML Studio Free Trial

Liquid XML Studio Editors and Debuggers


Graphical XML Schema Editor



Graphical XML Editor


FEATURE DETAILS XSLT Editor and Debugger

XSLT Editor and Debugger


FEATURE DETAILS XQuery Editor and Debugger

XQuery Editor and Debugger