9.2.4.3.3 Obtaining Data Values
In addition to matching paths, the XPath expressions can also be used to obtain data values, either absolutely or relative to the current node being processed. Data value expressions can contain any of the path elements in the preceding table, but must end with one of the value accessors listed below.
Value Accessors | Description |
---|---|
@att |
Some attribute value. |
text() |
The text content (value) of an element. |
content() |
The full content of an element, including any child XML nodes. |
name() |
The name of an element. |
position() |
The position of an element in its parent. |
Example 9-7 Examples of Extracting Data Values
To extract the relative element text value:
/My/Element/text()
To extract the absolute attribute value:
/My/Element/@att
To extract element text value with a match:
/My/Some[@att = 'value']/Sub/text()
Note:
Path accessors, such as ancestor/descendent/self, are not supported.
Parent topic: XPath Expressions