Module: MultiXml::Parsers::Nokogiri Private

Extended by:
Nokogiri
Includes:
DomParser
Included in:
Nokogiri
Defined in:
lib/multi_xml/parsers/nokogiri.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 Nokogiri library

Instance Method Summary collapse

Methods included from DomParser

#node_to_hash

Instance Method Details

#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 (IO)

    IO-like object containing XML

Returns:

  • (Hash)

    Parsed XML as a hash

Raises:

  • (Nokogiri::XML::SyntaxError)

    if XML is malformed



25
26
27
28
29
30
# File 'lib/multi_xml/parsers/nokogiri.rb', line 25

def parse(io)
  doc = ::Nokogiri::XML(io)
  raise doc.errors.first unless doc.errors.empty?

  node_to_hash(doc.root)
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:

  • (Class)

    Nokogiri::XML::SyntaxError



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

def parse_error = ::Nokogiri::XML::SyntaxError