Module: MultiXml::Parsers::Oga Private

Extended by:
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

API:

  • private

Instance Method Summary collapse

Methods included from DomParser

#node_to_hash

Instance Method Details

#collect_children(node, node_hash) ⇒ 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.

Parameters:

  • Parent node

  • Hash to populate

API:

  • private



38
39
40
41
42
43
44
45
# File 'lib/multi_xml/parsers/oga.rb', line 38

def collect_children(node, node_hash)
  each_child(node) do |child|
    case child
    when ::Oga::XML::Element then node_to_hash(child, node_hash)
    when ::Oga::XML::Text, ::Oga::XML::Cdata then node_hash[TEXT_CONTENT_KEY] << child.text
    end
  end
end

#parse(io) ⇒ 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

Parameters:

  • IO-like object containing XML

Returns:

  • Parsed XML as a hash

Raises:

  • if XML is malformed

API:

  • private



25
26
27
28
# File 'lib/multi_xml/parsers/oga.rb', line 25

def parse(io)
  doc = ::Oga.parse_xml(io)
  node_to_hash(doc.children.first)
end

#parse_errorClass

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.

Get the parse error class for this parser

Returns:

  • LL::ParserError

API:

  • private



17
# File 'lib/multi_xml/parsers/oga.rb', line 17

def parse_error = LL::ParserError