Module xmerl_xpath

The xmerl_xpath module handles the entire XPath 1.0 spec XPath expressions typically occurs in XML attributes and are used to addres parts of an XML document.

Description

The xmerl_xpath module handles the entire XPath 1.0 spec XPath expressions typically occurs in XML attributes and are used to addres parts of an XML document. The grammar is defined in xmerl_xpath_parse.yrl. The core functions are defined in xmerl_xpath_pred.erl.

Some useful shell commands for debugging the XPath parser

 c(xmerl_xpath_scan).
 yecc:yecc("xmerl_xpath_parse.yrl", "xmerl_xpath_parse", true, []).
 c(xmerl_xpath_parse).

 xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("position() > -1")).
 xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("5 * 6 div 2")).
 xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("5 + 6 mod 2")).
 xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("5 * 6")).
 xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("-----6")).
 xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("parent::node()")).
 xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("descendant-or-self::node()")).
 xmerl_xpath_parse:parse(xmerl_xpath_scan:tokens("parent::processing-instruction('foo')")).
  

Data Types

docEntity()

docEntity() = xmlElement() | xmlAttribute() | xmlText() | xmlPI() | xmlComment()

nodeEntity()

nodeEntity() = xmlElement() | xmlAttribute() | xmlText() | xmlPI() | xmlNamespace() | xmlDocument()

option_list()

abstract datatype: option_list()

Options allows to customize the behaviour of the XPath scanner.

Possible options are:
{namespace, #xmlNamespace}
Set namespace nodes, from XmlNamspace, in xmlContext
{namespace, Nodes}
Set namespace nodes in xmlContext.

Function Index

string/2

Equivalent to string(Str, Doc, []).

string/3

Equivalent to string(Str, Doc, [], Doc, Options).

string/5Extracts the nodes from the parsed XML tree according to XPath.

Function Details

string/2

string(Str::Str, Doc::Doc) -> docEntity()

Equivalent to string(Str, Doc, []).

string/3

string(Str::Str, Doc::Doc, Options::Options) -> docEntity()

Equivalent to string(Str, Doc, [], Doc, Options).

string/5

string(Str::Str, Node::Node, Parents::Parents, Doc::Doc, Options::Options) -> docEntity()

Extracts the nodes from the parsed XML tree according to XPath.