XML decoding data from SONG (extracted from db)

Hello all. I am newbie here, but I have little experiences with node-red.
So, please, I need a help, with extraction of data parsed from XML.
I think, data was parsed sucessfuly, but at the end I need only see (in text node) text from song under the _: as you may see in the figure here.
screen_nd_XML

Many thanks for your time.

Use the copy path option in the debug node, hover your mouse next to "_" and click copy path.
will be something like
payload.song.$.lyrics[0].verse[0]._
just add msg. to use in function node.

If you mean like this, sorry, this is script not running. Output is blank, without data.

var out1, msg1;
out1 = msg.payload.song.$.lyrics[0].verse[0]._;
msg1 = { payload: out1 };
return [msg1];

Did you attempt to copy the path, as my example was a educated guess, as I do not have your object and the image does not help. You can copy the payload object value in the debug to, then paste text.
e.g.

{"song":{"$":{"lyrics":[{"verse":[{"_":"test"}]}]}}}

here is an example flow i generate the object, but may not be as yours.

[{"id":"a11c8222d998d100","type":"inject","z":"da8a6ef0b3c9a5c8","name":"","props":[{"p":"payload.song.$.lyrics[0].verse[0]._","v":"test","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":45,"y":1600,"wires":[["dd4c5c1d5ec50b10","c1b0be2e2cdfb314"]],"l":false},{"id":"c1b0be2e2cdfb314","type":"ui_text","z":"da8a6ef0b3c9a5c8","group":"2d4fe667.28f8ba","order":18,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload.song.$.lyrics[0].verse[0]._}}","layout":"row-spread","className":"","x":290,"y":1620,"wires":[]},{"id":"dd4c5c1d5ec50b10","type":"debug","z":"da8a6ef0b3c9a5c8","name":"debug 217","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":445,"y":1580,"wires":[],"l":false},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

copy example to clipboard, then in editor press ctrl i or select import from menu. Paste clipboard and press import.

[edit]
Looking at your image again this may be your object.

{"song":{"$":{},"lyrics":[{"verse":[{"_":"test"}]}]}}

Here is another example.

[{"id":"a11c8222d998d100","type":"inject","z":"da8a6ef0b3c9a5c8","name":"","props":[{"p":"payload.song.$","v":"{}","vt":"json"},{"p":"payload.song.lyrics[0].verse[0]._","v":"test","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":45,"y":1600,"wires":[["dd4c5c1d5ec50b10","c1b0be2e2cdfb314"]],"l":false},{"id":"c1b0be2e2cdfb314","type":"ui_text","z":"da8a6ef0b3c9a5c8","group":"2d4fe667.28f8ba","order":18,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload.song.lyrics[0].verse[0]._}","layout":"row-spread","className":"","x":290,"y":1620,"wires":[]},{"id":"dd4c5c1d5ec50b10","type":"debug","z":"da8a6ef0b3c9a5c8","name":"debug 217","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":445,"y":1580,"wires":[],"l":false},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

The path maybe payload.song.lyrics[0].verse[0]._

This would be easier if you paste text and not images of objects.

Again you need to use copy path, you would also be better off if you spent a couple of hours to read the docs and watch the help videos.

Thanks, this is correct.Now I need only format it and will be super.

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