> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/components/system/output.md).

# Output

I capture the generated content from the body statements and save it into a variable

## Component Signature

```
<bx:Output query=[any]
group=[string]
groupCaseSensitive=[boolean]
startRow=[integer]
maxRows=[integer]
encodefor=[string] />
```

### Attributes

| Atrribute            | Type      | Required | Description | Default |
| -------------------- | --------- | -------- | ----------- | ------- |
| `query`              | `any`     | `false`  |             |         |
| `group`              | `string`  | `false`  |             |         |
| `groupCaseSensitive` | `boolean` | `false`  |             | `false` |
| `startRow`           | `integer` | `false`  |             |         |
| `maxRows`            | `integer` | `false`  |             |         |
| `encodefor`          | `string`  | `false`  |             |         |

## Examples

### Simple Tag Example

```java
<bx:output>Some text and a #encodeForHTML( variable )#</bx:output>
```

### Loop over a query

Loops over each row of the query specified and outputs the result.

```java
<bx:output query="news">
    <h2>#encodeForHTML( news.HEADLINE )#</h2>
    <p>#encodeForHTML( news.BYLINE )#</p>
</bx:output>
```

### Loop over a range of rows of a query

Loops over 10 rows of the query specified starting from row 5 and outputs the result.

```java
<bx:output query="news" startrow="5" maxrows="10">
    <h2>#encodeForHTML( news.HEADLINE )#</h2>
    <p>#encodeForHTML( news.BYLINE )#</p>
</bx:output>
```

### Using the encodeFor attribute

By specifying `encodefor="html"` each variable is encoded using the `encodeForHTML` function before it is output.

```java
<bx:output query="news" encodefor="html">
    <h2>#news.HEADLINE#</h2>
    <p>#news.BYLINE#</p>
</bx:output>
```

### Using the group attribute

Creates a dummy query `food`, with columns `name` and `type`. Then outputs the food by grouping by the type.

```java
<bx:set food = queryNew( "name,type", "varchar,varchar", [ 
	{
		NAME : "Apple",
		TYPE : "Fruit"
		},
	{
		NAME : "Orange",
		TYPE : "Fruit"
		},
	{
		NAME : "Chicken",
		TYPE : "Meat"
		}
	] ) >
<bx:output query="food" group="type">
    <h2>#type#</h2>
    <ul>
      <bx:output><li>#name#</li></bx:output>
    </ul>
</bx:output>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/components/system/output.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
