# XML decoding data from SONG (extracted from db)

**URL:** <https://discourse.nodered.org/t/xml-decoding-data-from-song-extracted-from-db/72957>\
**Category:** Dashboard\
**Created:** [30 December 2022 12:56 UTC](https://discourse.nodered.org/t/xml-decoding-data-from-song-extracted-from-db/72957 "2022-12-30T12:56:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felix](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@Felix](https://discourse.nodered.org/u/Felix)\
**Post date:** [30 December 2022 12:56 UTC](https://discourse.nodered.org/t/xml-decoding-data-from-song-extracted-from-db/72957/1 "2022-12-30T12:56:19Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/f/6f0deb48cc9466e6125899070e1452360e519970.jpeg)

Many thanks for your time.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 December 2022 13:01 UTC](https://discourse.nodered.org/t/xml-decoding-data-from-song-extracted-from-db/72957/2 "2022-12-30T13:01:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Felix](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@Felix](https://discourse.nodered.org/u/Felix)\
**Post date:** [30 December 2022 13:27 UTC](https://discourse.nodered.org/t/xml-decoding-data-from-song-extracted-from-db/72957/3 "2022-12-30T13:27:06Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 December 2022 13:36 UTC](https://discourse.nodered.org/t/xml-decoding-data-from-song-extracted-from-db/72957/4 "2022-12-30T13:36:27Z")

</div>

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.

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

```

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

```auto
[{"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.

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

```

Here is another example.

```auto
[{"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.

---

<div class="post-metadata">

**Author:** ![Felix](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@Felix](https://discourse.nodered.org/u/Felix)\
**Post date:** [30 December 2022 13:56 UTC](https://discourse.nodered.org/t/xml-decoding-data-from-song-extracted-from-db/72957/5 "2022-12-30T13:56:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 January 2023 13:56 UTC](https://discourse.nodered.org/t/xml-decoding-data-from-song-extracted-from-db/72957/6 "2023-01-13T13:56:46Z")

</div>

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