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
| # USAGE: Hash.from_libxml(YOUR_XML_STRING) | |
| # http://movesonrails.com/articles/2008/02/25/libxml-for-active-resource-2-0 | |
| require 'nokogiri' | |
| # updated because original version is written in 2 years ago. - memerelics | |
| class Hash | |
| class << self | |
| def from_libxml(xml) | |
| begin | |
| result = Nokogiri::XML(xml) | |
| return { result.root.name.to_s.to_sym => xml_node_to_hash(result.root)} |