Loading TOC...

XMLNode.xpath

XMLNode.xpath(
   $path as String,
   [$bindings as Object]
) as Sequence

Summary

This is inherited from the Node object.

Evaluate an XPath using the node as context.

Parameters
$path The XPath to evaluate.
$bindings Namespace bindings to use to interpret the XPath. The key is the prefix and the value is the namespace URI.

Required Privileges

http://marklogic.com/xdmp/privileges/xdmp-value

Usage Notes

The path is evaluated in the context of the current node, but it may be any valid XPath. Rooted paths will be confined to the current document, but they will not be confined to the subtree rooted at the current node. For example, the node.xpath("/title") will return the node <title>Here</title> regardless of which child of the following document the xpath method is called on:

<article>
  <title>Here</title>
  <subsection>
     <title>Subtitle</title>
     More stuff
  </subsection>
</article>

To get the subtitle of the subsection element, one would need to use the path ./title from the subsection element node.

Valid XPaths include more than just path expressions: arithmetic expressions, function calls, and so on are valid as well.

Example

var node = fn.head(cts.search("example"));
node.xpath("ex:section/ex:title", {"ex":"http://example.com/ns"})

Comments

    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy