XPath contains

Last modified: March 9, 2026

Overview

The contains() function tests whether a string attribute contains a specific string as a sub-string.

Syntax

The syntax is as follows:

contains ( attribute, string_expression )

attribute

attribute specifies the attribute to test. It must be of the String type.

expression

string_expression specifies the value to test for being contained in the attribute. It can be a string literal or a string parameter.

Example

This query returns all the customers from which the name contains the string an:

    [contains(Name, 'an')]
    
     //Sales.Customer[contains(Name, 'an')]
    

Customers with the name "Andy" or "Jan" will be returned, for example, because "an" is part of those names.