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)


17
18
19
# File 'lib/json/ld/html/rexml.rb', line 17

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})

Returns:



175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/json/ld/html/rexml.rb', line 175

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&.root
end