Orchestrator API Documentation: XPath Queries

by Simon Sparks · 11 February 2026

XPath uses path expressions to select nodes or node-sets in an XML document. The node is selected by following a path or steps.

XPath Selecting Nodes

ExpressionDescription
nodenameSelects all nodes with the name “nodename
/Selects from the root node
//Selects nodes in the document from the current node that match the selection no matter where they are.
.Selects the current node
..Selects the parent of the current node
@Selects attributes
*Matches any element node
@*Matches any attribute node

XPath Functions

FunctionDescription
last()Selects the last element that is the child of the parent element.
position()The position function returns a number equal to the context position from the expression evaluation context.
node()Matches any node of any kind
string-length( string or fieldname )The string-length function returns a number equal to the number of characters in a given string.
contains(haystack, needle)The contains function determines whether the first argument string contains the second argument string and returns boolean true or false.
not( expression )The not function evaluates a boolean expression and returns the opposite value.
starts-with(haystack, needle)The starts-with checks whether the first string starts with the second string and returns true or false.
substring(string, start)
substring(string, start, length)
The substring function returns a part of a given string.
translate(string, abc, XYZ)The translate function evaluates a string and a set of characters to translate and returns the translated string.

XPath Operators

OperatorDescription
|Computes two node-sets
+Addition
Subtraction
*Multiplication
divDivision
=Equal
!=Not Equal
<Less Than
<=Less Than or Equal To
>Greater Than
>=Greater Than or Equal To
orLogical OR
andLogical AND
modModulus ( division remainder )

Regular Expression Basics

OperatorDescription
(?i)Case Insensitive
^Start of string
$End of string

Examples

All XPath queries in orchestrator start the same as you can see below

let strXPathQuery:string = `xpath:`;
TypeScript

Equals

let strXPathQuery:string = `xpath:name='${strName}'`;
TypeScript

Matches

let strRegExp:string= `^${strName}$`;

let strXPathQuery:string = `xpath:matches(name,${strRegExp})`;
TypeScript

Matches Case Insensitive

let strRegExp:string= `(?i)^${strName}$`;

let strXPathQuery:string = `xpath:matches(name,${strRegExp})`;
TypeScript

Contains

let strXPathQuery:string `xpath:contains(name,'${strName}')`;
TypeScript

Not

let strXPathQuery:string = `xpath:not('${strName}'='test')`;
TypeScript

Starts-With

let strXPathQuery:string = `xpath:starts-with(name,'${strName}')`;
TypeScript

Substring

let strXPathQuery:string = `xpath:substring(name, ${intStartPosition}, ${intLength})`;
TypeScript

Translate to Upper Case

let strLowerCase:string = "abcdefghijklmnopqrstuvwxyz";
let strUpperCase:string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

let strXPathQuery:string = `xpath:translate(name, ${strLowerCase}, ${strUpperCase})='${strName.toUpperCase()}'`;
TypeScript

Translate to Lower Case

let strLowerCase:string = "abcdefghijklmnopqrstuvwxyz";
let strUpperCase:string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

let strXPathQuery:string = `xpath:translate(name, ${strUpperCase}, ${strLowerCase})='${strName.toLowerCase()}'`;
TypeScript

VMware Specific Use Case Examples

VcSdkConnection ID

let strXPathQuery:string = `xpath:sdkConnection/id='${objVcSdkConnection.id}'`;
TypeScript

VcSdkConnection ID and Name Equals

let strXPathQuery:string = `xpath:sdkConnection/id='${objVcSdkConnection.id}'`;

strXPathQuery = strXPathQuery + ` and name='${strName}'`;
TypeScript

VcSdkConnection ID and Name Contains

let strXPathQuery:string = `xpath:sdkConnection/id='${objVcSdkConnection.id}'`;

strXPathQuery = strXPathQuery + ` and contains(name, '${strName}')`;
TypeScript

Name Starts With

let strXPathQuery:string = `xpath:name[starts-with(.,'${strNamePrefix}')]`;
TypeScript

Template Equals and IsTemplate Equals and Name Starts With

let strXPathQuery: string = `xpath:summary/config/template='true'`;

strXPathQuery = strXPathQuery + ` and isTemplate='true'`;

strXPathQuery = strXPathQuery + ` and name[starts-with(.,'${strTempalateNamePrefix}')]`;
TypeScript

Template Equals and IsTemplate Equals and Name Equals and Not

let strXPathQuery: string = `xpath:summary/config/template='true'`;

strXPathQuery = strXPathQuery + ` and isTemplate='true'`;

strXPathQuery = strXPathQuery + ` and name='${strName}'`;

strXPathQuery = strXPathQuery + ` and not(summary/config/managedBy)``;
TypeScript

Property Matches Value

let strXPathQuery: string = `xpath:matches(${strProperty}, '${strValue}')`;
TypeScript

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like