Skip to content

Instantly share code, notes, and snippets.

@mchow01
Created October 17, 2014 23:03
Show Gist options
  • Save mchow01/6dd1f6e3f5a069407918 to your computer and use it in GitHub Desktop.
Save mchow01/6dd1f6e3f5a069407918 to your computer and use it in GitHub Desktop.
Using Nokogiri to Parse a XML File (hosted remotely)
@companies = []
begin
doc = Nokogiri::XML(open("https://rss.myinterfase.com/rss/tufts_Fall_Fair_2014_Empl_Reg_xml.xml"))
doc.css('Row').each do |elem|
# http://stackoverflow.com/questions/13520162/ruby-capitalize-every-word-first-letter
@companies << {:name => elem.css('orgname').text, :url => elem.css('reg_cnt_website').text}
end
@companies = @companies.sort_by{ |k| k[:name] }
rescue
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment