> For the complete documentation index, see [llms.txt](https://docs.datajet-app.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datajet-app.com/liquid/filters/parse_xml.md).

# parse\_xml

Parses an XML string into a Liquid object. Useful for processing XML feeds, API responses, and file imports.

```liquid
{% assign data = xml_string | parse_xml %}
{% log data %}
```

#### Syntax

```liquid
{{ xml_string | parse_xml }}
```

| Parameter    | Description                        |
| ------------ | ---------------------------------- |
| `xml_string` | A string containing valid XML data |

#### Return Value

Returns a Liquid object representing the XML structure. Elements become object keys, text content becomes values, and repeated elements become arrays.

#### Examples

**Parse an XML API response:**

```liquid
{% http url:"https://api.example.com/products.xml" method:"GET" as response %}
{% assign data = response.body | parse_xml %}
{% for product in data.products.product %}
  {% log product.title %}
{% endfor %}
```

**Parse an uploaded XML file:**

```liquid
{% assign data = file.content | parse_xml %}
{% log data %}
```

**Parse an XML feed and extract items:**

```liquid
{% assign feed = xml_content | parse_xml %}
{% assign items = feed.rss.channel.item %}
{% for item in items %}
  {% log item.title | append: " - " | append: item.link %}
{% endfor %}
```

**Process XML product feed:**

```liquid
{% assign catalog = file.content | parse_xml %}
{% assign products = catalog.catalog.products.product %}
{% for product in products %}
  {% log product.sku | append: ": " | append: product.name | append: " ($" | append: product.price | append: ")" %}
{% endfor %}
```

#### Notes

* Elements with text content are converted to their text value directly
* Repeated sibling elements with the same name become arrays
* Nested elements are preserved in the object structure
* Element attributes are not included; use `parse_xml_attrs` to keep them
* See also: `parse_xml_attrs`, `parse_json`, `parse_csv`
