---
url: /process-functions/datasource-parsexml.md
description: Reads an XML file and returns it as an object.
---

# datasource.parseXml

Reads an XML file and returns it as an object.

[datasource.readFile(filePath, "xml")](/process-functions/datasource-readFile) does the same, and also lets you choose the file's encoding.

```js
datasource.parseXml(filePath)
```

## Parameters

| Parameter | Type | Description |
|---|---|---|
| `filePath` | `string` | The path of the XML file. |

## Returns

The XML as an object. Elements become properties, repeated elements become arrays, and attributes and text appear as properties.

## Examples

```js
const invoice = datasource.parseXml("uploads/invoice.xml");
console.log(invoice.number);
```
