From deda012e03e4d3b92186f0607a084aff7458a3da Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Sun, 25 Oct 2020 22:19:44 +0000 Subject: [PATCH] fix(core): update --- test/test.ts | 2 ++ ts/index.ts | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/test.ts b/test/test.ts index bd79f15..3ff91f9 100644 --- a/test/test.ts +++ b/test/test.ts @@ -15,6 +15,8 @@ tap.test('should create an instance', async () => { tap.test('should create an xml string', async () => { const xmlResult = testSmartxml.createXmlFromObject({ hello: { + "@_xlmns:teststring": "hellothere", + "@_xlmns:testnumber": 10, wow: 'test' } }); diff --git a/ts/index.ts b/ts/index.ts index 97b6809..1f1a5fc 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -9,7 +9,10 @@ export class SmartXml { } public createXmlFromObject(jsObject: any): string { - const jsToXmlParser = new plugins.fastXmlParser.j2xParser({}); + const jsToXmlParser = new plugins.fastXmlParser.j2xParser({ + ignoreAttributes: false, + attributeNamePrefix: "@_" + }); const xml = jsToXmlParser.parse(jsObject); return xml; }