# Add property inside a XML string?

**URL:** <https://discourse.nodered.org/t/add-property-inside-a-xml-string/25615>\
**Category:** General\
**Created:** [27 April 2020 11:30 UTC](https://discourse.nodered.org/t/add-property-inside-a-xml-string/25615 "2020-04-27T11:30:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![smithtek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smithtek/32/17411_2.png) [@smithtek](https://discourse.nodered.org/u/smithtek)\
**Post date:** [27 April 2020 11:30 UTC](https://discourse.nodered.org/t/add-property-inside-a-xml-string/25615/1 "2020-04-27T11:30:23Z")

</div>

Hi.

Just wondering if it is possible in a function node to add/insert a value in the below XML txt.  
I had a good read, but this is above my knowledge level. Is a function node the right node to be using for Soap HTTP header and XML body/payload ?

When i make the auth call, i want to store the session key in flow.context then be able to access it in another flow and insert it in the XML.

Thanks

```auto
msg.payload = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetVehicleSnapShots xmlns="http://onlineavl2.navmanwireless.com/0907/"><request><Session><SessionId>HOW DO I ADD PROPERTY VALUE HERE</SessionId></Session><Version>1</Version><OwnerId>123456789</OwnerId><FetchTemperatureData>true</FetchTemperatureData><IncludeVehicleName>true</IncludeVehicleName></request></GetVehicleSnapShots></soap:Body></soap:Envelope>';

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [27 April 2020 13:08 UTC](https://discourse.nodered.org/t/add-property-inside-a-xml-string/25615/2 "2020-04-27T13:08:46Z")

</div>

Send the payload through an XML node (to change it to a JS object) --\> then a change node to change the desired property\* --\> then back through another XML node to convert the JS object back to XML

\* use a debug node to find the path to the property you want to change

---

<div class="post-metadata">

**Author:** ![smithtek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smithtek/32/17411_2.png) [@smithtek](https://discourse.nodered.org/u/smithtek)\
**Post date:** [27 April 2020 14:43 UTC](https://discourse.nodered.org/t/add-property-inside-a-xml-string/25615/3 "2020-04-27T14:43:06Z")

</div>

Magic. That did the trick, thanks Steve.

---

<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:** [11 May 2020 14:43 UTC](https://discourse.nodered.org/t/add-property-inside-a-xml-string/25615/4 "2020-05-11T14:43:10Z")

</div>

Closed on 11 May 2020 14:43 UTC

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