XPath Syntax Quick Reference

This topic provides a quick reference for XPath expression syntax.

Axes

XPath provides the following axes:

  • ancestor
  • ancestor-or-self
  • attribute
  • child
  • descendant
  • descendant-or-self
  • following
  • following-sibling
  • namespace
  • parent
  • preceding
  • preceding-sibling
  • self

Node Tests

XPath provides the following node tests:

  • * selects all nodes of the specified name. For the attribute axis, attributes are selected. For the namespace axis, namespace nodes are selected. For all other axes, element nodes are selected.
  • comment() selects all comment nodes.
  • element_name selects all element_name nodes.
  • node() selects all nodes.
  • processing-instruction(["some_literal "]) selects all processing instructions. If some_literal is specified, processing-instruction() selects all processing instructions with some_literal as their name.
  • text() selects all text nodes.

Filters

A filter specifies a constraint on a node set with respect to an axis to produce a new node set.

Location Steps

A location step has the following format:

AxisSpecifier
              ::NodeTest
              [Filter
              ][Filter
              ]...
               

            

XPath Expression

An XPath expression has one of the following formats:

LocationStep[/LocationStep]...
               
FunctionCall()[Filter]/LocationStep[/LocationStep]...
               
(Expression)[Filter]/LocationStep[/LocationStep]...
               

            

A function call or an XPath expression in parentheses can appear only at the very beginning of an XPath expression. An expression in parentheses always returns a node set. Any function that appears at the beginning of an XPath location step expression must return a node set.

XML Videos

Stylus Studio online XML video demonstrations illustrate how easy it is to learn advanced XML editing techniques. Now playing: Java Code Generation, Convert to XML, Grid View, and many other informative video demonstrations.

XML Operations

Using XML Pipeline it's easy to visually specify a series of XML operations to apply on your XML data, including parsing, validating, converting and transforming, according to the needs of your business application.

XMLSCHEMA-DEV Blog

XML Schema-DEV is an active community for XML Schema-releated development - join the discussion on XML Schema standards, tools, implementations and more. Bookmark this RSS or ATOM feed today!

MySQL XML Tools

The MySQL tools in Stylus Studio simplify XML related development tasks for working with MySQL and XML.

Stylus Most Wanted

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.