---
name: "xmerl_xpath"
section: "3erl"
platform: "linux"
package: "erlang-manpages"
version: "1:25.2.3+dfsg-1+deb12u4"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/xmerl_xpath"
---

# xmerl\_xpath(3erl)

The xmerl\_xpath module handles the entire XPath 1.0 spec.

## NAME

xmerl\_xpath - The xmerl\_xpath module handles the entire XPath 1.0 spec.

## DESCRIPTION

The xmerl\_xpath module handles the entire XPath 1.0 spec. XPath expressions typically occur in XML attributes and are used to address 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() = #xmlDocument{} \| \[docNodes()\]:**

  - **docNodes() = #xmlElement{} \| #xmlAttribute{} \| #xmlText{} \| #xmlPI{} \| #xmlComment{} \| #xmlNsNode{}:**

  - **nodeEntity() = #xmlElement{} \| #xmlAttribute{} \| #xmlText{} \| #xmlPI{} \| #xmlComment{} \| #xmlNsNode{} \| #xmlDocument{}:**

  - **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.

- **parentList() = \[{atom(), integer()}\]:**

  - **xPathString() = string():**

  ## EXPORTS

**string(Str, Doc) -\> \[docEntity()\] \| Scalar**\

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

**string(Str, Doc, Options) -\> \[docEntity()\] \| Scalar**\

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

**string(Str, Node, Parents, Doc, Options) -\> \[docEntity()\] \| Scalar**\

Types:

Str = xPathString()\
 Node = nodeEntity()\
 Parents = parentList()\
 Doc = nodeEntity()\
 Options = option\_list()\
 Scalar = #xmlObj{}\

Extracts the nodes from the parsed XML tree according to XPath. xmlObj is a record with fields type and value, where type is boolean \| number \| string

## AUTHORS

*\<\>*
