class Nokogiri::XML::Document

def parse(

[Returns] Nokogiri::XML::Document

can be configured before parsing. See Nokogiri::XML::ParseOptions for more information.
If a block is given, a Nokogiri::XML::ParseOptions object is yielded to the block which
[Yields]

+ParseOptions::DEFAULT_XML+.
behaviors during parsing. See ParseOptions for more information. The default value is
- +options:+ (Nokogiri::XML::ParseOptions) Configuration object that determines some

content.
document. When not provided, the encoding will be determined based on the document
- +encoding:+ (String) The name of the encoding that should be used when processing the

- +url:+ (String) The base URI for this document.
[Optional Keyword Arguments]

- +input+ (String | IO) The content to be parsed.
[Required Parameters]

that module's DEFAULT_XML constant for what's set (and not set) by default.
or access the network. See Nokogiri::XML::ParseOptions for a complete list of options; and
🛡 By default, Nokogiri treats documents as untrusted, and so does not attempt to load DTDs

Parse \XML input from a String or IO object, and return a new XML::Document.

parse(input, url:, encoding:, options:) => Nokogiri::XML::Document
parse(input) { |options| ... } => Nokogiri::XML::Document
call-seq:
def parse(
  string_or_io,
  url_ = nil, encoding_ = nil, options_ = XML::ParseOptions::DEFAULT_XML,
  url: url_, encoding: encoding_, options: options_
)
  options = Nokogiri::XML::ParseOptions.new(options) if Integer === options
  yield options if block_given?
  url ||= string_or_io.respond_to?(:path) ? string_or_io.path : nil
  if empty_doc?(string_or_io)
    if options.strict?
      raise Nokogiri::XML::SyntaxError, "Empty document"
    else
      return encoding ? new.tap { |i| i.encoding = encoding } : new
    end
  end
  doc = if string_or_io.respond_to?(:read)
    # TODO: should we instead check for respond_to?(:to_path) ?
    if string_or_io.is_a?(Pathname)
      # resolve the Pathname to the file and open it as an IO object, see #2110
      string_or_io = string_or_io.expand_path.open
      url ||= string_or_io.path
    end
    read_io(string_or_io, url, encoding, options.to_i)
  else
    # read_memory pukes on empty docs
    read_memory(string_or_io, url, encoding, options.to_i)
  end
  # do xinclude processing
  doc.do_xinclude(options) if options.xinclude?
  doc
end