Module: MultiXml::Parsers::DomParser Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Shared DOM traversal logic for converting XML nodes to hashes
Used by Nokogiri, LibXML, and Oga parsers. Including modules must implement:
- each_child(node) { |child| ... }
- each_attr(node) { |attr| ... }
- node_name(node) -> String
Instance Method Summary collapse
-
#node_to_hash(node, hash = {}) ⇒ Hash
private
Convert an XML node to a hash representation.
Instance Method Details
#node_to_hash(node, hash = {}) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Convert an XML node to a hash representation
19 20 21 22 23 24 25 26 |
# File 'lib/multi_xml/parsers/dom_parser.rb', line 19 def node_to_hash(node, hash = {}) node_hash = {TEXT_CONTENT_KEY => +""} add_value(hash, node_name(node), node_hash) collect_children(node, node_hash) collect_attributes(node, node_hash) strip_whitespace_content(node_hash) hash end |