From 2cc1f58f46cd12a26731ee6c1e516a3e720e497e Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Fri, 4 Feb 2022 12:16:34 +0100 Subject: [PATCH] :bug: Fix issue that XML node changes incoming data #2762 --- packages/nodes-base/nodes/Xml/Xml.node.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/nodes-base/nodes/Xml/Xml.node.ts b/packages/nodes-base/nodes/Xml/Xml.node.ts index f285fe0156..9443e738b4 100644 --- a/packages/nodes-base/nodes/Xml/Xml.node.ts +++ b/packages/nodes-base/nodes/Xml/Xml.node.ts @@ -234,6 +234,7 @@ export class Xml implements INodeType { let item: INodeExecutionData; + const returnData: INodeExecutionData[] = []; for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { try { @@ -253,15 +254,15 @@ export class Xml implements INodeType { // @ts-ignore const json = await parser.parseStringPromise(item.json[dataPropertyName]); - items[itemIndex] = { json }; + returnData.push({ json }); } else if (mode === 'jsonToxml') { const builder = new Builder(options); - items[itemIndex] = { + returnData.push({ json: { [dataPropertyName]: builder.buildObject(items[itemIndex].json), }, - }; + }); } else { throw new NodeOperationError(this.getNode(), `The operation "${mode}" is not known!`); } @@ -274,7 +275,7 @@ export class Xml implements INodeType { } } - return this.prepareOutputData(items); + return this.prepareOutputData(returnData); } }