xpath.evaluate
xpath.evaluate(sourceXML, expression[, namespaces, return_elements ])
Returns the result of evaluating the XPath expression against the XML string, or document returned from xpath.openDocument(). Returns a list of strings containing the selected values. The result is always a list, even if the expression is guaranteed to always return just one result.
When the XML document contains namespaces, by default the same namespace prefixes used in the XML should be used in the XPath expressions, including the empty default namespace. For example, consider an XML fragment:
<container xmlns="http://www.example.com/container_ns" xmlns:it="http://www.bmc.com/item_ns>
<it:item>This is the item</it:item>
</container>
The item text can be accessed with the expression "//container/it:item/text()
".
Alternatively, you may set the optional namespaces parameter to a table mapping prefixes to namespace URIs.
The expression is usually one that returns tag attributes or body text. By default, expressions returning DOM elements convert the result to the element's text(), meaning that an expression such as "//container/item
" is evaluated as "//container/item/text()
". If the optional return_elements parameter is set to true, then expressions specifying DOM elements return the DOM elements themselves, which can then be given back to xpath.evaluate() to evaluate further expressions. It is a runtime error to attempt to use a DOM element in any way other than as an input to xpath.evaluate().
Comments
Log in or register to comment.