Created
June 27, 2016 05:54
-
-
Save dineshsprabu/a80be0d1e80e17a57bd7b7a72182fb0f to your computer and use it in GitHub Desktop.
[RUBY] How to convert XML to HASH?
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
require 'active_support/core_ext/hash/conversions' | |
def xml_to_hash filename | |
doc = Nokogiri::XML.parse(File.open(filename)) | |
Hash.from_xml(doc.to_s) | |
end | |
p xml_to_hash 'file/to/path/filename.xml' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment