class Nokogiri::XML::SAX::ParserContext

instead.
💡 This class is usually not instantiated by the user. Use Nokogiri::XML::SAX::Parser
Context object to invoke the XML SAX parser on the SAX::Document handler.
##

def file(input, encoding = nil)

is more convenient for most use cases.
💡 Calling this method directly is discouraged. Use Nokogiri::XML::SAX::Parser.parse_file which

[Returns] Nokogiri::XML::SAX::ParserContext

use (default +nil+, encoding will be autodetected)
- +encoding+ (optional) (Encoding, String) The +Encoding+ to use, or the name of an encoding to
- +path+ (String) The path to the input file
[Parameters]

Create a parser context for the file at +path+.

file(path, encoding)
file(path)
:call-seq:
##
def file(input, encoding = nil)
  native_file(input, resolve_encoding(encoding))
end

def io(input, encoding = nil)


methods which are more convenient for most use cases.
💡 Calling this method directly is discouraged. Use Nokogiri::XML::SAX::Parser parse

[Returns] Nokogiri::XML::SAX::ParserContext

encoding to use (default +nil+, encoding will be autodetected)
- +encoding+ (optional) (Encoding) The +Encoding+ to use, or the name of an
- +io+ (IO) The readable IO object from which to read input
[Parameters]

Create a parser context for an +input+ IO which will assume +encoding+

io(input, encoding)
io(input)
:call-seq:
##
def io(input, encoding = nil)
  native_io(input, resolve_encoding(encoding))
end

def memory(input, encoding = nil)


which are more convenient for most use cases.
💡 Calling this method directly is discouraged. Use Nokogiri::XML::SAX::Parser parse methods

[Returns] Nokogiri::XML::SAX::ParserContext

use (default +nil+, encoding will be autodetected)
- +encoding+ (optional) (Encoding, String) The +Encoding+ to use, or the name of an encoding to
- +input+ (String) The input string to be parsed.
[Parameters]

Create a parser context for the +input+ String.

memory(input, encoding)
memory(input)
:call-seq:
##
def memory(input, encoding = nil)
  native_memory(input, resolve_encoding(encoding))
end

def new(input, encoding = nil)


[Returns] Nokogiri::XML::SAX::ParserContext

otherwise it forwards to ParserContext.memory.
If +input+ quacks like a readable IO object, this method forwards to ParserContext.io,

encoding to use (default +nil+, encoding will be autodetected)
- +encoding+ (optional) (Encoding) The +Encoding+ to use, or the name of an
- +input+ (IO, String) A String or a readable IO object
[Parameters]

ParserContext.io and ParserContext.memory.
Create a parser context for an IO or a String. This is a shorthand method for

new(input, encoding)
new(input)
:call-seq:
##
def new(input, encoding = nil)
  if [:read, :close].all? { |x| input.respond_to?(x) }
    io(input, encoding)
  else
    memory(input, encoding)
  end
end

def resolve_encoding(encoding)

def resolve_encoding(encoding)
ncoding
ncoding
ding
il
# totally fine, parser will guess encoding
nteger
("Passing an integer to Nokogiri::XML::SAX::ParserContext.io is deprecated. Use an Encoding object instead. This will become an error in a future release.", uplevel: 2, category: :deprecated)
rn nil if encoding == Parser::ENCODINGS["NONE"]
ding = Parser::REVERSE_ENCODINGS[encoding]
e ArgumentError, "Invalid libxml2 encoding id #{encoding}" if encoding.nil?
ding.find(encoding)
tring
ding.find(encoding)
e ArgumentError, "Cannot resolve #{encoding.inspect} to an Encoding"