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

Defined in:
vendor/bundler/ruby/2.6.0/bundler/gems/json-ld-94ee7791d19f/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:



14
15
16
# File 'vendor/bundler/ruby/2.6.0/bundler/gems/json-ld-94ee7791d19f/lib/json/ld/html/rexml.rb', line 14

def self.library
  :rexml
end

Instance Method Details

#initialize_html(input, options = {}) ⇒ NodeProxy

Initializes the underlying XML library.

Parameters:

Returns:



172
173
174
175
176
177
178
179
180
181
182
183
# File 'vendor/bundler/ruby/2.6.0/bundler/gems/json-ld-94ee7791d19f/lib/json/ld/html/rexml.rb', line 172

def initialize_html(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