Skip to content

Simplified XPath

hunterhacker edited this page Oct 13, 2011 · 3 revisions

Simplified XPath

Simplified XPath statements look and feel exactly like traditional XPath 1.0 statements but only support positional predicates, not boolean predicates. For example, here are some valid simplified XPath statements:

foo/bar[1]
foo/@bar
foo/ancestor::bar
foo/following-sibling::bar
foo[1]/bar[2]

Notice how all the predicates simply contain positional information (fetch me the first bar or the second baz). Predicates that contain logic (eg: foo[bar = "baz"]) are not valid.

Supported XPath Axis

  • ancestor::
  • ancestor-or-self::
  • attribute:: (@ shortcut is also supported)
  • child::
  • descendant::
  • descendant-or-self:: (// shortcut is also supported)
  • following::
  • following-sibling::
  • preceding::
  • preceding-sibling::
  • namespace::
  • parent:: (.. shortcut is also supported)
  • self::

Discussion

Or expressions like /message/headers/(a|b) aren't allowed. They'd sure be handy though.

Clone this wiki locally