Problem XML to JSON data converted

Hi,

When I am converting the XML to JSON and when I try to extract data from JSON I am getting errors and when I did some searching it lead me to the Data is not parsing correcelty in JSON format.

I am try to extract specific data using CODE and this what I have wreiten :smile:

const hostList = $input.json[ā€œHOST_LIST_VM_DETECTION_OUTPUTā€][ā€œRESPONSEā€][ā€œHOST_LISTā€][ā€œHOSTā€];
const endResult = [];

for (let i = 0; i < hostList.length; i++) {
endResult.push({
ā€œIDā€: hostList[i][ā€œIDā€],
ā€œIPā€: hostList[i][ā€œIPā€],
ā€œNETBIOSā€: hostList[i][ā€œNETBIOSā€],
ā€œRESULTSā€: hostList[i][ā€œDETECTION_LISTā€][ā€œDETECTIONā€][0][ā€œRESULTSā€]
});
}

return endResult;

Any one help me with this

Hi @techbrooks, I am sorry to hear you’re having trouble.

Perhaps you can confirm which data you are passing on to your Code node and which error exactly you are seeing? Testing your snippet with a generic workflow including made up data like below is working fine for me (on [email protected]) once I swap in suitable variables from this list and wrap it around the example code looping through items:

This would be the result:

Thank You very much for your reply I have resolved my problem watched one of the n8n youtube video where they explain how to use the javascript in n8n and I was able to work with it.

Thank You again for looking into it.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.