Something to convert in XML?

#1

I'm facing a problem now. I need to convert some datas (in function node) in XML to connect an API... but the current XML syntax is not accepted in Node Red function Node:

For example my object is named : WifiAccessPoints
But on the other side, the API is waiting for : access-point

What is the right solution to rename WifiAccessPoints in access-point without errors in my function node?

Thanks...

0 Likes

#2

This page might be of use https://www.w3schools.com/js/js_object_properties.asp

0 Likes

#3

Thanks... but I did not see any relative answer... as here, the problem is to write a composed name with a - in the middle, which I don't know how it is supported in my function node or in javascript (I don't know javascript)...

0 Likes

#4

use key notation eg

objectName["property"] // person["age"]

0 Likes

#5

I'm sorry but I still can't see where is the relation....

Can someone please explain me how to replace wifiAccessPoints with access-point in answer.wifiAccessPoints and in answer.wifiAccessPoints.push, in the code below??

let i;
answer.wifiAccessPoints = []
    if (answer.flag === "V") {
        let wifiAccessPointsStrings = elements[5].split("&")
        let j;
        for (j = 0; j < wifiAccessPointsStrings.length; j++) {
            let baseElements = wifiAccessPointsStrings[j].split("|")
            answer.wifiAccessPoints.push({ ssid: baseElements[0], macAddress: baseElements[1], signalStrength: baseElements[2] })  
    }
      answer.baseCountwifiAccessPoints = answer.wifiAccessPoints.length
}
0 Likes

#6
msg["test-123"]=[];
msg["test-123"].push=({ ssid: "ssid", macAddress:"the mac address" });
return msg;
0 Likes

#7

You saved my day !!! Thanks...

0 Likes