Created
November 3, 2009 16:56
-
-
Save bcalloway/225218 to your computer and use it in GitHub Desktop.
Parse XML file with Nokogiri
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xml = File.read("db/getLocationsForUrl.xml") | |
@doc = Nokogiri::XML.parse(xml) | |
locations = [] | |
locations.push("<option value=\"\">-- Select a Location --</option>") | |
@doc.xpath('/env:Envelope/env:Body/Array/item/return/item').each do |node| | |
id = node.xpath('id') | |
name = node.xpath('name') | |
locations.push("<option value=\"#{id.text}\">#{name.text}</option>") | |
end | |
return locations |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment