---
title: xml (DataFrameWriter)
description: "DataFrameWriter.xml method in PySpark: Saves the content of the DataFrame in XML format at the specified path."
canonical_url: https://docs.databricks.com/gcp/en/pyspark/reference/classes/dataframewriter/xml
---

# xml (DataFrameWriter)

Saves the content of the `DataFrame` in XML format at the specified path.

## Syntax

```
xml(path, rowTag=None, mode=None, attributePrefix=None, valueTag=None,
    rootTag=None, declaration=None, arrayElementName=None, nullValue=None,
    dateFormat=None, timestampFormat=None, compression=None, encoding=None,
    validateName=None)
```

## Parameters

| Parameter | Type          | Description                                                                                                                                     |
| --------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `path`    | str           | The path in any Hadoop-supported file system.                                                                                                   |
| `mode`    | str, optional | The behavior when data already exists. Accepted values are `'append'`, `'overwrite'`, `'ignore'`, and `'error'` or `'errorifexists'` (default). |

## Returns

None

## Examples

Write a DataFrame into an XML file and read it back.

```python
import tempfile
with tempfile.TemporaryDirectory(prefix="xml") as d:
    spark.createDataFrame(
        [{"age": 100, "name": "Alice"}]
    ).write.mode("overwrite").option("rowTag", "person").xml(d)

    spark.read.option("rowTag", "person").format("xml").load(d).show()
    # +---+------------+
    # |age|        name|
    # +---+------------+
    # |100|Alice|
    # +---+------------+
```
