Module: MultiXML::Parsers::Oga Private
- Extended by:
- MultiXML::Parser, Oga
- Includes:
- DomParser
- Included in:
- Oga
- Defined in:
- lib/multi_xml/parsers/oga.rb
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.
XML parser using the Oga library
Constant Summary collapse
- ParseError =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Exception class raised on Oga parse failure
LL::ParserError
Instance Method Summary collapse
-
#collect_children(node, node_hash, mode) ⇒ void
private
Collect child nodes into a hash (Oga-specific implementation).
-
#parse(io, namespaces: :strip) ⇒ Hash
private
Parse XML from an IO object.
Methods included from MultiXML::Parser
Methods included from DomParser
Instance Method Details
#collect_children(node, node_hash, mode) ⇒ void
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.
This method returns an undefined value.
Collect child nodes into a hash (Oga-specific implementation)
Oga uses different node types than Nokogiri/LibXML.
39 40 41 42 43 44 45 46 |
# File 'lib/multi_xml/parsers/oga.rb', line 39 def collect_children(node, node_hash, mode) each_child(node) do |child| case child when ::Oga::XML::Element then node_to_hash(child, node_hash, mode: mode) when ::Oga::XML::Text, ::Oga::XML::Cdata then node_hash[TEXT_CONTENT_KEY] << child.text end end end |
#parse(io, namespaces: :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.
Parse XML from an IO object
25 26 27 28 |
# File 'lib/multi_xml/parsers/oga.rb', line 25 def parse(io, namespaces: :strip) doc = ::Oga.parse_xml(io) node_to_hash(doc.children.first, mode: namespaces) end |