XRules Home

CWM XPath

CWM_XPath is a built-in for CWM that allows CWM to evaluate XPath expressions and select nodes from XML.
Implements the functions: selectSingleNode, selectNodes, and evaluate.

Source

Documentation

selectSingleNode: Selects a single XML node.

Subject: A two-item list containing XML text and an XPath expression.
Object: The text of the first node selected by the XPath expression. If the node has child nodes, the text of all child nodes is concatenated and returned.
use:
("<Order><Item>Book</Item><Item>Pen</Item></Order>" "/Order/Item") xpath:selectSingleNode :node .
Result: "Book"

 

selectNodes: Selects a list of XML nodes.

Subject: A two-item list containing XML text and an XPath expression.
Object: A list of strings representing the text of the nodes selected by the XPath expression.
use:
("<Order><Item>Book</Item><Item>Pen</Item></Order>" "/Order/Item") xpath:selectNodes :nodes .
Result: ( "Book", "Pen" )

 

evaluate: Evaluates an XPath expression.

Subject: A two-item list containing XML text and an XPath expression.
Object: A number or string that is the result of evaluating the XPath expression.
use:
("<Order><Item>Book</Item><Item>Pen</Item></Order>" "/Order/Item") xpath:evaluate :value .
Result: 2