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
| Parameter | Type | Description |
|---|---|---|
filePath | string | The path of the XML file. |
Returns
objectThe 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);