smartxml/ts/index.ts

16 lines
445 B
TypeScript
Raw Normal View History

2020-10-24 15:47:12 +00:00
import * as plugins from './smartxml.plugins';
2020-10-24 16:39:37 +00:00
export class SmartXml {
constructor() {}
public parseXmlToObject<T = any>(xmlStringArg: string): T {
const jsonObject = plugins.fastXmlParser.convertToJson(xmlStringArg);
return jsonObject;
}
public createXmlFromObject(jsObject: any): string {
const jsToXmlParser = new plugins.fastXmlParser.j2xParser({});
const xml = jsToXmlParser.parse(jsObject);
return xml;
}
}