# String/Object message handling

**URL:** <https://discourse.nodered.org/t/string-object-message-handling/38011>\
**Category:** General\
**Created:** [25 December 2020 19:34 UTC](https://discourse.nodered.org/t/string-object-message-handling/38011 "2020-12-25T19:34:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nbra](https://avatars.discourse-cdn.com/v4/letter/n/dec6dc/32.png) [@Nbra](https://discourse.nodered.org/u/Nbra)\
**Post date:** [25 December 2020 19:34 UTC](https://discourse.nodered.org/t/string-object-message-handling/38011/1 "2020-12-25T19:34:01Z")

</div>

Hi,

Iv`e reached the end of my string here with a get/http return message from a IP camera where I will extract some data to make a download link. The request message returns a string with:

```auto
?xml version="1.0"?>

<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.axis.com/vapix/http_cgi/recording/list1.xsd">

  <recordings totalnumberofrecordings="9" numberofrecordings="9"> <recording diskid="SD_DISK" recordingid="20201225_124627_148A_ACCC8E9C6AC1" starttime="2020-12-25T11:46:27.875685Z" starttimelocal="2020-12-25T12:46:27.875685+01:00" stoptime="2020-12-25T19:11:56.181874Z" stoptimelocal="2020-12-25T20:11:56.181874+01:00" recordingtype="continuous" eventid="continuous_0" eventtrigger="continuous" recordingstatus="recording" source="1" locked="No"> <video mimetype="video/x-h264" width="1920" height="1080" framerate="30:1" resolution="1920x1080"/>
    </recording>
    <recording diskid="SD_DISK" recordingid="20201129_213935_328F_ACCC8E9C6AC1" starttime="2020-11-29T20:39:35.215442Z" starttimelocal="2020-11-29T21:39:35.215442+01:00" stoptime="2020-11-29T20:43:39.712775Z" stoptimelocal="2020-11-29T21:43:39.712775+01:0....

```

 ![GET Recording](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/472ed8509360656875ffee7c19e4a62691b64b5d.png)

And so it continues depending on the number of recordings. Im trying to extract all data between **recordingid=** \< and \> **recording type** , seperated so I can push them on to a UI list where each recording will push the needed data via a function and get request.

Is moving it from a string to an array and digging into indexOf() functions the correct path?

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [25 December 2020 21:25 UTC](https://discourse.nodered.org/t/string-object-message-handling/38011/2 "2020-12-25T21:25:07Z")

</div>

Since the reply from your Http request is an XML you can use the **XML node** to parse the payload into a JS object. After that pickup the information you need with the Copy path icon .

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/8/b8e963cbb37ba818ccb5ba418c0175cb4e318506.png)  
.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d4dcc38097cd6c24c4aeeba14068e2067a0938b6.png) .

**Example :**

```auto
[{"id":"76977231.73b1fc","type":"inject","z":"32cacc4b.b57a94","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":400,"y":320,"wires":[["5221803c.f899a8"]]},{"id":"23c44139.8d1a7e","type":"xml","z":"32cacc4b.b57a94","name":"","property":"payload","attr":"","chr":"","x":370,"y":440,"wires":[["b84fbcdc.80ac3"]]},{"id":"b84fbcdc.80ac3","type":"debug","z":"32cacc4b.b57a94","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":370,"y":500,"wires":[]},{"id":"5221803c.f899a8","type":"function","z":"32cacc4b.b57a94","name":"","func":"msg.payload = ` \n<?xml version=\"1.0\"?>\n<root xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.axis.com/vapix/http_cgi/recording/list1.xsd\">\n<recordings totalnumberofrecordings=\"9\" numberofrecordings=\"9\"> \n<recording diskid=\"SD_DISK\" recordingid=\"20201225_124627_148A_ACCC8E9C6AC1\" starttime=\"2020-12-25T11:46:27.875685Z\" starttimelocal=\"2020-12-25T12:46:27.875685+01:00\" stoptime=\"2020-12-25T19:11:56.181874Z\" stoptimelocal=\"2020-12-25T20:11:56.181874+01:00\" recordingtype=\"continuous\" eventid=\"continuous_0\" eventtrigger=\"continuous\" recordingstatus=\"recording\" source=\"1\" locked=\"No\"> \n<video mimetype=\"video/x-h264\" width=\"1920\" height=\"1080\" framerate=\"30:1\" resolution=\"1920x1080\"/>\n</recording>\n<recording diskid=\"SD_DISK\" recordingid=\"20201129_213935_328F_ACCC8E9C6AC1\" starttime=\"2020-11-29T20:39:35.215442Z\" starttimelocal=\"2020-11-29T21:39:35.215442+01:00\" stoptime=\"2020-11-29T20:43:39.712775Z\" stoptimelocal=\"2020-11-29T21:43:39.712775+01:00\" recordingtype=\"continuous\" eventid=\"continuous_0\" eventtrigger=\"continuous\" recordingstatus=\"recording\" source=\"2\" locked=\"No\">\n<video mimetype=\"video/x-h264\" width=\"1920\" height=\"1080\" framerate=\"30:1\" resolution=\"1920x1080\"/>\n</recording>\n</recordings>\n</root>\n`\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":380,"y":380,"wires":[["23c44139.8d1a7e"]]}]

```

---

<div class="post-metadata">

**Author:** ![Nbra](https://avatars.discourse-cdn.com/v4/letter/n/dec6dc/32.png) [@Nbra](https://discourse.nodered.org/u/Nbra)\
**Post date:** [25 December 2020 21:52 UTC](https://discourse.nodered.org/t/string-object-message-handling/38011/3 "2020-12-25T21:52:08Z")

</div>

Brilliant, that got me to where I needed, many 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:** [8 January 2021 21:52 UTC](https://discourse.nodered.org/t/string-object-message-handling/38011/4 "2021-01-08T21:52:11Z")

</div>

Closed on 8 January 2021 21:52 UTC

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