smartxml/ts/index.ts
2020-10-25 22:19:44 +00:00

19 lines
505 B
TypeScript

import * as plugins from './smartxml.plugins';
export class SmartXml {
constructor() {}
public parseXmlToObject<T = any>(xmlStringArg: string): T {
const jsonObject = plugins.fastXmlParser.parse(xmlStringArg);
return jsonObject;
}
public createXmlFromObject(jsObject: any): string {
const jsToXmlParser = new plugins.fastXmlParser.j2xParser({
ignoreAttributes: false,
attributeNamePrefix: "@_"
});
const xml = jsToXmlParser.parse(jsObject);
return xml;
}
}