Created
February 2, 2011 17:19
-
-
Save elucid/808021 to your computer and use it in GitHub Desktop.
Crack::XML attribute parsing
This file contains hidden or 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
| 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