fix(core): update
This commit is contained in:
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartxml',
|
||||
version: '1.0.7',
|
||||
description: 'a package for creating and parsing xml formated files'
|
||||
}
|
@ -1,21 +1,22 @@
|
||||
import * as plugins from './smartxml.plugins';
|
||||
import * as plugins from './smartxml.plugins.js';
|
||||
|
||||
export class SmartXml {
|
||||
constructor() {}
|
||||
|
||||
public parseXmlToObject<T = any>(xmlStringArg: string): T {
|
||||
const jsonObject = plugins.fastXmlParser.parse(xmlStringArg);
|
||||
const parser = new plugins.fastXmlParser.XMLParser();
|
||||
const jsonObject = parser.parse(xmlStringArg);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
public createXmlFromObject(jsObject: any): string {
|
||||
const jsToXmlParser = new plugins.fastXmlParser.j2xParser({
|
||||
const jsToXmlParser = new plugins.fastXmlParser.XMLBuilder({
|
||||
ignoreAttributes: false,
|
||||
attributeNamePrefix: "@_",
|
||||
format: true,
|
||||
indentBy: ' ',
|
||||
});
|
||||
const xml = jsToXmlParser.parse(jsObject);
|
||||
const xml = jsToXmlParser.build(jsObject);
|
||||
return '<?xml version="1.0" encoding="UTF-8"?>\n' + xml;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user