class Nokogiri::XML::Document
Public Instance Methods
to_hash()
click to toggle source
# File lib/nokogiri/xml/document_to_hash.rb, line 4 def to_hash children_to_hash(children) end
Private Instance Methods
children_to_hash(children)
click to toggle source
# File lib/nokogiri/xml/document_to_hash.rb, line 9 def children_to_hash(children) hash = {} children.each do |child| if child.children.any? if hash.key?(child.name.to_sym) hash[child.name.to_sym] = [ hash[child.name.to_sym], children_to_hash(child.children) ] else hash[child.name.to_sym] = children_to_hash(child.children) end else hash = child.content.to_s end end hash end