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_element_attr(node) { |attr| ... } (non-namespace-decl attrs only)
- each_namespace_decl(node) { |prefix_or_nil, uri| ... }
- element_parts(node) -> [prefix_or_nil, local_name]
- attr_parts(attr) -> [prefix_or_nil, local_name]
Instance Method Summary collapse
-
#node_to_hash(node, hash = {}, mode: :strip) ⇒ Hash
private
Convert an XML node to a hash representation.
Instance Method Details
#node_to_hash(node, hash = {}, mode: :strip) ⇒ 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
29 30 31 32 33 34 35 36 37 |
# File 'lib/multi_xml/parsers/dom_parser.rb', line 29 def node_to_hash(node, hash = {}, mode: :strip) node_hash = {TEXT_CONTENT_KEY => +""} add_value(hash, format_element_name(node, mode), node_hash) collect_children(node, node_hash, mode) collect_namespace_decls(node, node_hash, mode) collect_attributes(node, node_hash, mode) strip_whitespace_content(node_hash) hash end |