# Write an XML or HTML file

Publish / file

write XML, HTML

Page: <https://meridian.online/operations/write-an-xml-or-html-file>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today, with the `webbed` extension.

## The DuckDB step

rows rendered as XML and written to a file

It reads the `orders` table the proofs share. Create it first:

```sql
CREATE TABLE orders AS SELECT * FROM (VALUES
  (1,  'Alice Ng',      'north', DATE '2026-01-03', 120.00, 'widget', 'a|b',   '{"channel":"web","items":[1,2]}'),
  (2,  'alice ng',      'north', DATE '2026-01-05',  80.50, 'gadget', 'b',     '{"channel":"shop","items":[3]}'),
  (3,  'Bob  Okafor',   'south', DATE '2026-01-05', 300.00, 'widget', 'a|c',   '{"channel":"web","items":[4,5,6]}'),
  (4,  'Carla Díaz',    'east',  DATE '2026-01-09',  NULL,  'gizmo',  NULL,    '{"channel":"web","items":[]}'),
  (5,  'Bob Okafor',    'south', DATE '2026-01-12',  45.25, 'gadget', 'c',     '{"channel":"phone","items":[7]}'),
  (6,  'Dev Patel',     'west',  DATE '2026-01-12', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (7,  'Carla Diaz',    'east',  DATE '2026-01-20',  99.99, 'gizmo',  'b|c',   '{"channel":"shop","items":[10]}'),
  (8,  'Dev Patel',     'west',  DATE '2026-02-02', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (9,  'Eve Larsen',    NULL,    DATE '2026-02-03',  15.00, 'gadget', NULL,    '{"channel":"web","items":[11]}'),
  (10, 'Alice Ng',      'north', DATE '2026-02-10', 220.00, 'gizmo',  'a|b|c', '{"channel":"phone","items":[12,13]}')
) t(order_id, customer, region, order_date, amount, product, tags, meta);
```

Then run the statement:

```sql
INSTALL webbed FROM community; LOAD webbed;
COPY (SELECT to_xml({'order_id': order_id, 'customer': customer, 'amount': amount}) AS doc FROM orders) TO '<your_scratch_dir>/orders.xml' (FORMAT csv, HEADER false, QUOTE '');
CREATE TEMP TABLE result AS
SELECT len(regexp_extract_all(content, '<customer>')) AS customers, len(regexp_extract_all(content, '<order_id>')) AS ids, content LIKE '%<customer>Dev Patel</customer>%' AS has_dev FROM read_text('<your_scratch_dir>/orders.xml');
SELECT * FROM result;
SELECT CASE WHEN ((SELECT customers = 10 AND ids = 10 AND has_dev FROM result)) THEN 'as expected' ELSE error('the file does not hold ten order elements') END AS verdict;
```

Replace `<your_scratch_dir>` with a directory of your own that you can write to before running the statement.

The statement writes `orders.xml` itself, in `<your_scratch_dir>`.

It needs the `webbed` extension.

## Variants

- Write an RSS or Atom feed: Write rows as the items of an RSS or Atom feed.
- Write an HTML table: Write the rows as an HTML table.
- Write rows as XML: Write rows as XML elements, flat or built into a nested tree.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 86.2% of 312 rows (exact class, version 2).

- Duckle: [`XML`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- EasyMorph: [`Export to XML`](https://help.easymorph.com/doku.php?id=transformations:exportxml) (read 2026-09-27)
- Apache Hop: [`XML Output`](https://hop.apache.org/manual/latest/pipeline/transforms/xmloutput.html) (read 2026-09-27)
- Apache Hop: [`XML output (Advanced)`](https://hop.apache.org/manual/latest/pipeline/transforms/xmloutputadvanced.html) (read 2026-09-27)
- KNIME Analytics Platform: [`XML Row Combine and Write`](https://api.hub.knime.com/nodes/*p1CBl0U1TyBx5_LZ?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`XML Writer`](https://api.hub.knime.com/nodes/*va9aGvJa-MJpjGjX?details=full) (read 2026-09-27)
- Apache NiFi: [`XMLRecordSetWriter`](https://nifi.apache.org/components/org.apache.nifi.xml.XMLRecordSetWriter/) (read 2026-09-27)
- OpenRefine: [`HTML-formatted table`](https://openrefine.org/docs/manual/exporting#export-data) (read 2026-09-27)
- Pentaho Data Integration: [`RSS Output`](https://docs.pentaho.com/pdia-data-integration/9.3-data-integration/pdi-transformation-steps-reference-overview) (read 2026-09-27)
- Pentaho Data Integration: [`XML Output`](https://docs.pentaho.com/pdia-data-integration/9.3-data-integration/pdi-transformation-steps-reference-overview) (read 2026-09-27)
- RapidMiner Studio: [`Write XRFF`](https://docs.rapidminer.com/latest/studio/operators/data_access/files/write/write_xrff.html) (read 2026-09-27)
- Talend: [`tAdvancedFileOutputXML`](https://help.qlik.com/talend/en-US/components/8.0/xml-connectors/xml-connectors-component) (read 2026-09-27)
- Talend: [`tFileOutputMSXML`](https://help.qlik.com/talend/en-US/components/8.0/ms-xml-connectors/ms-xml-connectors-component) (read 2026-09-27)
- Talend: [`tFileOutputXML`](https://help.qlik.com/talend/en-US/components/8.0/xml-connectors/xml-connectors-component) (read 2026-09-27)
- Talend: [`tRSSOutput`](https://help.qlik.com/talend/en-US/components/8.0/rss/rss-component) (read 2026-09-27)
- VisiData: [`html (saver)`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/loaders/html.py#L213) (read 2026-09-23)
- VisiData: [`xml (saver)`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/loaders/xml.py#L252) (read 2026-09-23)
