# Convert data string to payload value

**URL:** <https://discourse.nodered.org/t/convert-data-string-to-payload-value/73861>\
**Category:** General\
**Created:** [18 January 2023 13:14 UTC](https://discourse.nodered.org/t/convert-data-string-to-payload-value/73861 "2023-01-18T13:14:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomasoggier](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thomasoggier/32/74571_2.png) [@thomasoggier](https://discourse.nodered.org/u/thomasoggier)\
**Post date:** [18 January 2023 13:14 UTC](https://discourse.nodered.org/t/convert-data-string-to-payload-value/73861/1 "2023-01-18T13:14:53Z")

</div>

Hello,  
Using websockets request, I get some data from the node in a long string and I need to convert it into readable data.  
The data I get looks:  
`msg.payload= <Navigation id='0x4f7248'><item id='0x513f30'><name>Temperatures</name></item>`

And I would like to convert it into:

```auto
...
msg.payload.item_id='0x514880'
msg.payload.name = "Temperatures"
...

```

Or someting like that.  
Someone could help me?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [18 January 2023 13:43 UTC](https://discourse.nodered.org/t/convert-data-string-to-payload-value/73861/2 "2023-01-18T13:43:00Z")

</div>

Try first passing it through the XML node. It looks like an xml snippet. I'm not sure how fussy that node is for "correct" xml though. Otherwise, we need to get into some serious string find and replace.

---

<div class="post-metadata">

**Author:** ![thomasoggier](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thomasoggier/32/74571_2.png) [@thomasoggier](https://discourse.nodered.org/u/thomasoggier)\
**Post date:** [18 January 2023 14:36 UTC](https://discourse.nodered.org/t/convert-data-string-to-payload-value/73861/3 "2023-01-18T14:36:49Z")

</div>

Thanks, exacly what I was looking for.  
Works perfecty thanks

---

<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:** [1 February 2023 14:37 UTC](https://discourse.nodered.org/t/convert-data-string-to-payload-value/73861/4 "2023-02-01T14:37:04Z")

</div>

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