How do I parse XML from an API response?

This topic was automatically generated from Slack. You can find the original thread here.

Franklin Bindels : Hey everybody, Any tips on parsing xml from an api response? I have a zillow response that is xml and I need separate fields :slightly_smiling_face:

Dylan Sather (Pipedream) : take a look at xml-js - npm . That’s the package I use to convert XML to its JavaScript object equivalent, which makes it easier to reference the data in the XML

Dylan Sather (Pipedream) : does that help?

Franklin Bindels : I tried that actually now I have like JSON, but still don’t know how to use the fields in another step of pipedream

Franklin Bindels :

Dylan Sather (Pipedream) : It looks like the results are being returned as a JSON string. When you return the data from your step, can you try running JSON.parse() on it? For example, if you’re running:

return data

now, can you try running

return JSON.parse(data)

instead?

Dylan Sather (Pipedream) : That should return a structured JavaScript object whose values you can reference more easily by property

Franklin Bindels : That did it, thanks so much dude! You the man,

Dylan Sather (Pipedream) : That’s great!