Module: MultiXml::Parsers::NokogiriSax Private

Defined in:
lib/multi_xml/parsers/nokogiri_sax.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.

SAX-based parser using Nokogiri (faster for large documents)

Defined Under Namespace

Classes: Handler

Class Method Summary collapse

Class Method Details

.parse(xml) ⇒ 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 a string or IO object

Parameters:

  • xml (String, IO)

    XML content

Returns:

  • (Hash)

    Parsed XML as a hash

Raises:

  • (Nokogiri::XML::SyntaxError)

    if XML is malformed



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

def parse(xml)
  io = xml.respond_to?(:read) ? xml : StringIO.new(xml)
  return {} if io.eof?

  handler = Handler.new
  ::Nokogiri::XML::SAX::Parser.new(handler).parse(io)
  handler.result
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_sax.rb', line 17

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