var i;
var j;
var nr = 1;for (i = 0; i < msg.payload.TripList.Trip.length; i++) {
output = 'Verbindung ' + nr++;
for (j = 0; j < msg.payload.TripList.Trip[i].LegList[0].Leg.length; j++) {output += "\r\n-----\r\nZugtyp: " + msg.payload.TripList.Trip[i].LegList[0].Leg[j].$.name + "\r\nStartbahnhof: " + msg.payload.TripList.Trip[i].LegList[0].Leg[j].Origin[0].$.name + "\r\nStartzeit: " + msg.payload.TripList.Trip[i].LegList[0].Leg[j].Origin[0].$.time + "\r\nZielbahnhof: " + msg.payload.TripList.Trip[i].LegList[0].Leg[j].Destination[0].$.name + "\r\nAnkuftszeit: " + msg.payload.TripList.Trip[i].LegList[0].Leg[j].Destination[0].$.time; } msg.payload.type = 'message' msg.payload.chatId = msg.originalMessage.from.id; msg.payload.content = output
return msg;
//node.send(msg);
}
With node.send (msg); I get one message per trip.
Unfortunately asynchronous.
With "return msg" I get only the first message of the array. The loop then seems to end. How do I get the complete array synchronized?