Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export const parseXMLFastXML = async (
xml: string
): Promise<Record<string, any>> => {
// Load the external dependency
const { XMLParser } = await import("npm:fast-xml-parser");
// Set some default options so we don't ignore attributes
const xmlOptions = {
ignoreAttributes: false,
attributeNamePrefix: "@_",
ignoreDeclaration: true,
};
// Setup the parser with options
const parser = new XMLParser(xmlOptions);
return parser.parse(xml);
};
October 23, 2023