Get an XML Response

2 Enter a location in the Address input and click Generate Code to test the Choreo from our website.

3 You get a whole bunch of XML in the Response output with lots of weather-related information about the location. Next we'll see how to parse through this response in Ruby and pick out only the pieces we're interested in.

Parse it in Ruby

4 Create a new Ruby class and copy in the code below. Steps 5 & 6 talk you through what happens in the code.

5 First we have to convert the XML response from Yahoo to a w3c.Document object.

6 Next we need to parse out the data we want from the XML file. It helps to look at the XML file's structure to get an idea of how it is organized. We want the text and temp attributes. You can find them in:<channel><yweather:condition>.

7That's it. You can run the code to try it out. You should see a message bout the weather condition including its text and temp printed in the console.

What next?

Now you're ready to tackle all sorts of XML parsing tasks. You can find tons of Choreos that return XML in our Library.

Once you've got your code up and running, you're ready to move on and do more. From monitoring your running applications, to moving your generated Temboo code to your preferred development environment and sharing it with colleagues, collaborators and friends - we've got you covered.

Commit Code to GitHub

Commit Temboo-generated code directly to GitHub and share with the world. Learn more.

Need help?

We're always happy to help. Just email us at support@temboo.com, and we'll answer your questions.