Add property inside a XML string?


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.


msg.payload = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap=""><soap:Body><GetVehicleSnapShots xmlns=""><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>';

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

Magic. That did the trick, thanks Steve.

1 Like

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