Home > Blockchain >  Unable to parse XML object
Unable to parse XML object

Time:12-20

(I don't use Node-Red for a long time but I have some knowledge of Javascript syntax using NodeJS and client side libraries like jQuery.)

I can read my file and parse it correctly. Data object is valid (see green arrow) and syntax to access structured object is good.

let arr = msg.payload
    .VariablesExchangeFile
    .DDTSource[0]
    .structure[0]
    .variables;

return arr;

But My arr variable is empty (see red arrow) !!! And I don't understand why.

details of problem

I copied the path to the child object from debug Window, and it's the same path (see yellow shapes) : payload.VariablesExchangeFile.DDTSource[0].structure[0].variables

CodePudding user response:

The variable is not empty, the problem is that you are not returning a msg object from the function node.

You are returning the array object which does not have a payload field and you have the debug node set to only print out the msg.payload field.

Change the function node as follows:

let msg.payload = msg.payload
    .VariablesExchangeFile
    .DDTSource[0]
    .structure[0]
    .variables;

return msg;
  • Related