Module: JSON::LD::API::REXML

Defined in:
lib/json/ld/html/rexml.rb

Overview

REXML implementation of an XML parser.

Defined Under Namespace

Classes: NodeProxy, NodeSetProxy

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.librarySymbol

Returns the name of the underlying XML library.

Returns:

  • (Symbol)


14
15
16
# File 'lib/json/ld/html/rexml.rb', line 14

def self.library
  :rexml
end

Instance Method Details

#initialize_html_rexml(input, options = {}) ⇒ NodeProxy Also known as: initialize_html

Initializes the underlying XML library.

Parameters:

  • options (Hash{Symbol => Object}) (defaults to: {})

Returns:



172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/json/ld/html/rexml.rb', line 172

def initialize_html_rexml(input, options = {})
  require 'rexml/document' unless defined?(::REXML)
  doc = case input
  when ::REXML::Document
    input
  else
    # Only parse as XML, no HTML mode
    ::REXML::Document.new(input.respond_to?(:read) ? input.read : input.to_s)
  end

  NodeProxy.new(doc.root) if doc && doc.root
end