Skip to content

Instantly share code, notes, and snippets.

@rjfranco
Created April 13, 2011 03:57
Show Gist options
  • Save rjfranco/916942 to your computer and use it in GitHub Desktop.
Save rjfranco/916942 to your computer and use it in GitHub Desktop.
Attempting to do Each on XML object created using XmlSimple Gem
require 'net/http'
require 'rubygems'
require 'xmlsimple'
=begin
Sample Object in XML
<?xml version="1.0" encoding="UTF-8"?>
<ADS>
<AD>
<JOB_ID>401448</JOB_ID>
<DATE_POSTED>2011-04-13</DATE_POSTED>
<DATE_EXPIRE>2011-05-13</DATE_EXPIRE>
<CLASS>S305</CLASS>
<FIELDS>
<EVENTNAME>Columbia Dance Summer Moves! Dance Camp</EVENTNAME>
<DATEHours>06/27/11-07/01/11 M-F 9:30-3:00pm</DATEHours>
<Cost>$275.00</Cost>
<AgeGroup>4-6</AgeGroup>
<Location>1700 Broadway St., Vancouver WA</Location>
<Contact></Contact>
</FIELDS>
<ADTEXT>&lt;B&gt; Columbia Dance Summer Moves! Dance Camp&lt;BR&gt; &lt;/B&gt; &lt;B&gt; Ages: &lt;/B&gt;4-6&lt;BR&gt; &lt;B&gt; Time &amp; Dates: &lt;/B&gt; 06/27/11-07/01/11 M-F 9:30-3:00pm&lt;BR&gt; &lt;B&gt; Cost: &lt;/B&gt;$275.00&lt;BR&gt; &lt;B&gt; Location: &lt;/B&gt;1700 Broadway St., Vancouver WA&lt;BR&gt; &lt;B&gt; Description: &lt;BR&gt; &lt;/B&gt;Join us this summer and enjoy as we explore. We will have Creative Dance, Ballet and Modern techniques, wonderful dance art projects, choreography, videos, stories, dance games and a final exciting performance for families and friends. </ADTEXT>
</AD>
</ADS>
=end
xmldata = XmlSimple.xml_in('summercamp-2011-data.xml')
xmldata['AD'].each do |ad|
puts ad[JOB_ID]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment