Skip to content

datasource.parseXml ​

Reads an XML file and returns it as an object.

datasource.readFile(filePath, "xml") does the same, and also lets you choose the file's encoding.

js
datasource.parseXml(filePath)

Parameters ​

ParameterTypeDescription
filePathstringThe path of the XML file.

Returns ​

object

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);