---
title: xPath
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/xmlnode/xpath
---

# xPath

Returns the XPath expression identifying the receiver’s location in the document tree.

## Declaration

```swift
var xPath: String? { get }
```

## Discussion

Discussion For example, this method might return a string such as “foo/bar[2]/baz”. The result of this method can be used directly in the nodes(forXPath:) and objects(forXQuery:constants:) methods.

## See Also

### Executing Queries

- [nodes(forXPath:)](foundation/xmlnode/nodes(forxpath:).md)
- [objects(forXQuery:)](foundation/xmlnode/objects(forxquery:).md)
- [objects(forXQuery:constants:)](foundation/xmlnode/objects(forxquery:constants:).md)
