---
title: "XPathExpression | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Interface XPathExpression

This interface is a compiled XPath expression that can be evaluated on a document or specific node to return information from its DOM tree.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/XPathExpression)

interface XPathExpression {  
    [evaluate](#evaluate-1)(  
        contextNode: [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/),  
        type?: number,  
        result?: [XPathResult](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.XPathResult/) | null,  
    ): [XPathResult](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.XPathResult/);  
}

##### Index

### Methods[](#methods)

[evaluate](#evaluate)

## Methods[](#methods-1)

### evaluate[](#evaluate)

-   evaluate(  
        contextNode: [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/),  
        type?: number,  
        result?: [XPathResult](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.XPathResult/) | null,  
    ): [XPathResult](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.XPathResult/)[](#evaluate-1)
    
    The **`evaluate()`** method of the XPathExpression interface executes an XPath expression on the given node or document and returns an XPathResult.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/XPathExpression/evaluate)
    
    #### Parameters
    
    -   contextNode: [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/)
    -   `Optional`type: number
    -   `Optional`result: [XPathResult](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.XPathResult/) | null
    
    #### Returns [XPathResult](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.XPathResult/)
