# Guidance for parsing & manipulating data from an API

**URL:** <https://discourse.nodered.org/t/guidance-for-parsing-manipulating-data-from-an-api/66510>\
**Category:** General\
**Created:** [16 August 2022 16:41 UTC](https://discourse.nodered.org/t/guidance-for-parsing-manipulating-data-from-an-api/66510 "2022-08-16T16:41:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Corey](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@Corey](https://discourse.nodered.org/u/Corey)\
**Post date:** [16 August 2022 16:41 UTC](https://discourse.nodered.org/t/guidance-for-parsing-manipulating-data-from-an-api/66510/1 "2022-08-16T16:41:41Z")

</div>

Hi, I'm accessing data from an API and am triggering the I/O on a RevPi based on the data. I'm wondering on the best approach to parse the data and act on it. My programming now is becoming somewhat unwieldy.

I have the data coming back in an XML format. The structure is something like this:

```auto
object
payload: object
DispatchEventResult: object
$: object
DispatchEventList: array[1]
0: object
DispatchEvent: array[35]
[0 … 9]
0: object
DemandEventSourceType: array[1]
EndDate: array[1]
EventId: array[1]
FacilityName: array[1]
IsInternalTestEvent: array[1]
IsTestEvent: array[1]
IsoId: array[1]
IsoName: array[1]
MeterId: array[1]
MeterName: array[1]
ProductTypeId: array[1]
ProductTypeName: array[1]
ProgramName: array[1]
ResourceId: array[1]
StartDate: array[1]
ZoneId: array[1]
ZoneName: array[1]
1: object
2: object
3: object
4: object
5: object
6: object
7: object
8: object
9: object
[10 … 19]
[20 … 29]
[30 … 34]

```

What I would like to do is be able to look through each array and store the specified data, since the number of arrays can change. Right now I have the switch node storing objects and a function node but it's static and if the number of arrays change it will not work. How can I parse through this entire object and store the data associated with object:EventId?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [17 August 2022 05:40 UTC](https://discourse.nodered.org/t/guidance-for-parsing-manipulating-data-from-an-api/66510/2 "2022-08-17T05:40:18Z")

</div>

Did you go through the documentation "[working with messages](https://nodered.org/docs/user-guide/messages)" ?

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [17 August 2022 06:00 UTC](https://discourse.nodered.org/t/guidance-for-parsing-manipulating-data-from-an-api/66510/3 "2022-08-17T06:00:29Z")

</div>

Also it would be worthwhile posting up your current flow, with some real data in the debug window and an idea of how much of the data you want to access - what do you want to happen when the array length changes ? How do you identify and access the specific information you are interested in ?

Craig

---

<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:** [16 October 2022 06:00 UTC](https://discourse.nodered.org/t/guidance-for-parsing-manipulating-data-from-an-api/66510/4 "2022-10-16T06:00:34Z")

</div>

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