I am using rest-client to make restful API calls. My response can be either in JSON or XML.
How can I easily parse the responses? It is pulling Company and Contact information.
Is there a way to treat each XML record as an object, so I can access the tags as methods?
What is the recommended way to access and traverse the response I get back, and is it XML or JSON as the recommended format?
In the Readme of the ‘maintained’ github repo for the ruby version of rest-client, there is a section on handling results.
Are you calling two different APIs? I’m unsure of how one API would be both returning XML and/or JSON?
Personally, I’d make the call with rest-client (instead of net::http or something) and then use REXML to then parse the information I needed.
example (hypothetical with no code):
For information on parsing with REXML check out this tutorial