Module: XmlMini_Nokogiri::Conversions::Node
- Includes:
- NodeHash
- Defined in:
- lib/xml_mini/nokogiri.rb
Constant Summary
Constants included from NodeHash
Instance Method Summary collapse
-
#to_hash(hash = {}) ⇒ Object
Convert XML document to hash.
Methods included from NodeHash
#handle_child_element, #insert_node_hash_into_parent, #remove_blank_content_node
Instance Method Details
#to_hash(hash = {}) ⇒ Object
Convert XML document to hash
- hash
-
Hash to merge the converted element into.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/xml_mini/nokogiri.rb', line 40 def to_hash(hash={}) node_hash = {} # Insert node hash into parent hash correctly. insert_node_hash_into_parent(hash, name, node_hash) # Handle child elements children.each do |child| handle_child_element(child, node_hash) end # Remove content node if it is empty and there are child tags remove_blank_content_node node_hash # Handle attributes attribute_nodes.each { |a| node_hash[a.node_name] = a.value } hash end |