# Xpath10 paths

`xpath10-paths` · version 1.0.0 · Structured formats · free, no key needed

List the canonical XPath 1.0 path of each node in a location-path node-set, in document order.

**Use when you need to: canonical xpath 1.0 path of each match · absolute location path for selected xml nodes · xpath path list in document order.**

## Decide before calling

Read the [versioned contract](/v1/tools/xpath10-paths/versions/1.0.0) and the supported scope below. Reuse `xpath10-paths@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `xpath10-paths@1.0.0` for canonical xpath 1.0 path of each match. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- canonical xpath 1.0 path of each match
- absolute location path for selected xml nodes
- xpath path list in document order
- where each xpath match sits in the document
- stable xpath pointer for a node set
- generate reselectable xpath 1.0 paths

## Not supported

- XPath 2.0 paths and XSLT match patterns
- rewriting the document or evaluating a non-node-set expression
- arithmetic, variables and general XPath functions

## Behavior

- Same node-set as xpath10-select. Each node is replaced by one absolute path that selects that node again with the same namespace map.
- The root path is /. An un-namespaced element uses its local name and a 1-based index among siblings of the same expanded-name, omitted only when it is the only such sibling.
- A namespaced element is *[i] among all element siblings, always with the index. An un-namespaced attribute is @local. A namespaced attribute is @*[i] in source order.
- A namespace node is namespace::prefix, or namespace::*[i] when the prefix is empty. text(), comment() and processing-instruction('target') omit [i] only when that group has one node.
- Joining a step onto / produces /step, never //step. Union order does not change the path list; duplicates are removed before the paths are emitted.
- /doc/chapter[5]/section[2] is both the XPath 1.0 abbreviated example and the canonical path of that section when five chapters exist and the fifth has two sections.

## Input

- `xml` (string, required): min length 1; max length 4096
- `expression` (string, required): min length 1; max length 1024
- `namespaces` (object, optional)

## Output

- `count` (integer, required): min 0; max 400
- `paths` (array of string, required): max items 400; each min length 1; each max length 16384

## Limits

- max xml bytes: 4096
- max expression bytes: 1024
- max depth: 32
- max nodes: 400
- max steps: 100000
- max output bytes: 32768
- max namespace bindings: 16
- max namespace uri bytes: 512
- max name chars: 256
- max union operands: 32
- max xpath depth: 32

## Example

Request input:

```json
{
  "xml": "<doc><para>A</para><para>B</para></doc>",
  "expression": "//para"
}
```

Response:

```json
{
  "result": {
    "count": 2,
    "paths": [
      "/doc/para[1]",
      "/doc/para[2]"
    ]
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "xpath10-paths",
  "version": "1.0.0",
  "input": {
    "xml": "<doc><para>A</para><para>B</para></doc>",
    "expression": "//para"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/xpath10-paths/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"xml":"<doc><para>A</para><para>B</para></doc>","expression":"//para"}'
```

The machine-readable contract is at [/v1/tools/xpath10-paths/versions/1.0.0](/v1/tools/xpath10-paths/versions/1.0.0).

### CLI

```sh
node cli.mjs run xpath10-paths 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Xpath10 count](/tools/xpath10-count): Count the nodes in an XPath 1.0 node-set from location paths, axes, predicates, namespaces and union.
- [Xpath10 select](/tools/xpath10-select): Select an XPath 1.0 node-set from location paths, axes, predicates, namespaces and union, in document order.
- [XML exc c14n canonicalize](/tools/xml-exc-c14n-canonicalize): Exclusive XML Canonicalization 1.0 of a whole document, with an optional inclusive prefix list.
- [XML exc c14n subtree](/tools/xml-exc-c14n-subtree): Exclusive XML Canonicalization 1.0 of one selected element and its descendants.
- [Xpath10 boolean](/tools/xpath10-boolean): Evaluate an XPath 1.0 boolean expression: comparisons, and, or, not, starts-with, contains, and boolean conversion.
- [Xpath10 evaluate](/tools/xpath10-evaluate): Evaluate an XPath 1.0 value expression and return its type with an exact string, number, or boolean token.
