---
title: "Syntax for indexing XPath"
slug: "syntax-for-indexing-xpath"
updated: 2025-06-11T14:30:11Z
published: 2025-06-11T14:30:11Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.catchpoint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Syntax for indexing XPath

## Overview

The Syntax for indexing XPath differs when used directly to reference an individual element on a page as opposed to xxxxxxxx. In such scenarios, it is necessary to use "()" to specify the element is being referenced globally.

## Examples

### indexing use for child element

`XPath: //div[@class="blue"]/div[@class="red"][2]`

In the above example, a `div` element with `class="blue"` will be located. Next, it will search for the immediate child `div` element with `class="red"` and will select the second match.

### global reference

`(//div[@class="red"])[2]`

In the above example, all div elements with `class="red"` will be located. Use of `()[2]` specifies to select the second match of the returned result.

See also: [Scripting Tips and Best Practices](https://docs.catchpoint.com/docs/Scripting-Tips-and-Best-Practices)
