Skip to content

Instantly share code, notes, and snippets.

@elucid
Created February 2, 2011 17:19
Show Gist options
  • Select an option

  • Save elucid/808021 to your computer and use it in GitHub Desktop.

Select an option

Save elucid/808021 to your computer and use it in GitHub Desktop.
Crack::XML attribute parsing
require 'rubygems'
require 'crack'
xml = <<EOX
<credits>
<credit currency="GBP">100</credit>
<credit currency="USD">150</credit>
</credits>
EOX
parsed = Crack::XML.parse xml
parsed['credits']['credit'].first.attributes['currency']
# => "GBP"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment