Saxon API for .NET |

# XPathCompiler.Compile Method

Compile an expression supplied as a String.

public XPathExecutable Compile(
string source
);

#### Parameters

source
  A string containing the source text of the XPath expression

#### Return Value

An `XPathExecutable` which represents the compiled xpath expression object. The XPathExecutable may be run as many times as required, in the same or a different thread. The `XPathExecutable` is not affected by any changes made to the `XPathCompiler` once it has been compiled.

#### Remarks

Using this method the XPath processor is provided with a string of Unicode characters, so no decoding is necessary. Any encoding information present in the version declaration is therefore ignored.

#### Example

                XPathExecutable q = compiler.Compile("distinct-values(//*/node-name()");

#### See Also

XPathCompiler Class | Saxon.Api Namespace