Loading TOC...

BooleanNode.xpath

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

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

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.

Comments

The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.