# Xpath10 select

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

Select an XPath 1.0 node-set from location paths, axes, predicates, namespaces and union, in document order.

**Use when you need to: select xml nodes with xpath 1.0 · xpath 1.0 node set from location path · evaluate xpath axes predicates and union.**

## Decide before calling

Read the [versioned contract](/v1/tools/xpath10-select/versions/1.0.0) and the supported scope below. Reuse `xpath10-select@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-select@1.0.0` for select xml nodes with xpath 1.0. 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

- select xml nodes with xpath 1.0
- xpath 1.0 node set from location path
- evaluate xpath axes predicates and union
- match elements attributes and namespaces by xpath
- xpath absolute and relative location path
- filter xml nodes with xpath predicates

## Not supported

- XPath 2.0 eq, except, intersect and wildcard *:local tests
- arithmetic, variables, and functions other than position() and last()
- DOCTYPE, DTD and XML versions other than 1.0
- returning a count or a canonical path (use xpath10-count and xpath10-paths)

## Behavior

- Context node is the document root. Relative paths start there, so doc/para equals /doc/para when doc is the document element.
- The expression is a union of location paths and parenthesized filters, using all 13 axes, abbreviations, name tests, and predicates. The path / is the root node-set.
- Predicates run per context node in proximity order. //para[1] is the first para child of each parent. (//para)[1] is the first para in document order.
- Comparisons follow XPath 1.0 section 3.4, including existential node-set tests. != is not the negation of =.
- Unprefixed names match the null namespace only. The xml prefix is always http://www.w3.org/XML/1998/namespace and cannot be rebound.
- Results are deduplicated and emitted in pinned document order: root, then each element, its namespace nodes sorted by prefix, its attributes in source order, then its children.
- String-value of a root or element is descendant text only. A quoted ] or an attribute value containing > is data, not a closer.
- Arithmetic, variables, functions other than position() and last(), XPath 2.0 syntax, DOCTYPE and non-1.0 XML are unsupported_input. Limits fail with limit_exceeded.

## 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
- `nodes` (array of object, required): max items 400

## 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>Hi</para></doc>",
  "expression": "/doc/para"
}
```

Response:

```json
{
  "result": {
    "count": 1,
    "nodes": [
      {
        "kind": "element",
        "name": "para",
        "namespace_uri": "",
        "string_value": "Hi"
      }
    ]
  }
}
```

## How to call it

### MCP

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

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

### HTTP (no key)

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

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

### CLI

```sh
node cli.mjs run xpath10-select 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 paths](/tools/xpath10-paths): List the canonical XPath 1.0 path of each node in a location-path node-set, in document order.
- [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.
- [Xpath10 string](/tools/xpath10-string): Evaluate an XPath 1.0 expression that yields a string, including concat, substring, translate, and string conversion.
