4 Commits

Author SHA1 Message Date
5481831711 1.0.6 2020-10-26 00:44:27 +00:00
fb606e734b fix(core): update 2020-10-26 00:44:26 +00:00
e75a939214 1.0.5 2020-10-25 22:19:44 +00:00
deda012e03 fix(core): update 2020-10-25 22:19:44 +00:00
4 changed files with 13 additions and 5 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartxml",
"version": "1.0.4",
"version": "1.0.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartxml",
"version": "1.0.4",
"version": "1.0.6",
"private": false,
"description": "a package for creating and parsing xml formated files",
"main": "dist_ts/index.js",

View File

@@ -15,7 +15,10 @@ tap.test('should create an instance', async () => {
tap.test('should create an xml string', async () => {
const xmlResult = testSmartxml.createXmlFromObject({
hello: {
wow: 'test'
"@_xlmns:teststring": "hellothere",
"@_xlmns:testnumber": 10,
wow: 'test',
url: [{loc: 3},{loc: 3}]
}
});
console.log(xmlResult);

View File

@@ -9,8 +9,13 @@ export class SmartXml {
}
public createXmlFromObject(jsObject: any): string {
const jsToXmlParser = new plugins.fastXmlParser.j2xParser({});
const jsToXmlParser = new plugins.fastXmlParser.j2xParser({
ignoreAttributes: false,
attributeNamePrefix: "@_",
format: true,
indentBy: ' ',
});
const xml = jsToXmlParser.parse(jsObject);
return xml;
return '<?xml version="1.0" encoding="UTF-8"?>\n' + xml;
}
}