# eval Action

Evaluates its text content as an XPath expression. The result can be assigned to a variable.

```markup
<eval out="$mock">false()</eval>
```

The action is mostly used to assign variables.

Besides atomic values such as strings, numbers and booleans, an expression may yield a DOM node-set:

```markup
<eval out="$parts">split($request/path, "/")</eval>
```

```markup
<eval out="$links">content()/html/body//a[@href] | content()/html/head/link[@href]</eval>
```

If you need to create a structured JSON object use [templating](https://sevenval.gitbook.io/flat/reference/templating).

## Syntax

The action body must contain an XPath expression.

`out` is optional. If defined, it must contain a variable name. If no `out` is given, the result is discarded.

Omitting output is useful to call functions with side-effects:

```markup
<eval>fit-log(concat("login error for user ", $request/post/username))</eval>
```

## See also

* [Variables](https://sevenval.gitbook.io/flat/reference/variables)
* [`template`](https://sevenval.gitbook.io/flat/reference/actions/template)
* [JSON Templating](https://sevenval.gitbook.io/flat/reference/templating)
