class Nokogiri::HTML::Document

def self.new(*args) # :nodoc:

:nodoc:
def self.new(*args) # :nodoc:
  uri         = args[0]
  external_id = args[1]
  doc = wrap(LibXML.htmlNewDoc(uri, external_id))
  doc.send :initialize, *args
  doc
end

def self.read_io(io, url, encoding, options) # :nodoc:

:nodoc:
def self.read_io(io, url, encoding, options) # :nodoc:
  wrap_with_error_handling do
    LibXML.htmlReadIO(IoCallbacks.reader(io), nil, nil, url, encoding, options)
  end
end

def self.read_memory(string, url, encoding, options) # :nodoc:

:nodoc:
def self.read_memory(string, url, encoding, options) # :nodoc:
  wrap_with_error_handling do
    LibXML.htmlReadMemory(string, string.length, url, encoding, options)
  end
end

def fragment tags = nil

Create a Nokogiri::XML::DocumentFragment from +tags+
###
def fragment tags = nil
  DocumentFragment.new(self, tags, self.root)
end

def meta_content_type

def meta_content_type
  css('meta[@http-equiv]').find { |node|
    node['http-equiv'] =~ /\AContent-Type\z/i
  }
end

def meta_encoding

then nil is returned.
Get the meta tag encoding for this document. If there is no meta tag,
##
def meta_encoding
  meta = meta_content_type and
    /charset\s*=\s*([\w-]+)/i.match(meta['content'])[1]
end

def meta_encoding= encoding

content tag, the encoding is not set.
Set the meta tag encoding for this document. If there is no meta
##
def meta_encoding= encoding
  meta = meta_content_type and
    meta['content'] = "text/html; charset=%s" % encoding
end

def parse string_or_io, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML

Nokogiri::XML::ParseOptions.
Nokogiri::XML::ParseOptions::RECOVER. See the constants in
is a number that sets options in the parser, such as
encoding that should be used when processing the document. +options+
+url+ is resource where this document is located. +encoding+ is the
responds to _read_ and _close_ such as an IO, or StringIO.
Parse HTML. +thing+ may be a String, or any object that
##
def parse string_or_io, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML
  options = Nokogiri::XML::ParseOptions.new(options) if Fixnum === options
  # Give the options to the user
  yield options if block_given?
  if string_or_io.respond_to?(:encoding)
    unless string_or_io.encoding.name == "ASCII-8BIT"
      encoding ||= string_or_io.encoding.name
    end
  end
  if string_or_io.respond_to?(:read)
    url ||= string_or_io.respond_to?(:path) ? string_or_io.path : nil
    if !encoding
      # Perform advanced encoding detection that libxml2 does
      # not do.
      string_or_io = EncodingReader.new(string_or_io)
      begin
        return read_io(string_or_io, url, encoding, options.to_i)
      rescue EncodingFoundException => e
        # A retry is required because libxml2 has a problem in
        # that it cannot switch encoding well in the middle of
        # parsing, especially if it has already seen a
        # non-ASCII character when it finds an encoding hint.
        encoding = e.encoding
      end
    end
    return read_io(string_or_io, url, encoding, options.to_i)
  end
  # read_memory pukes on empty docs
  return new if string_or_io.nil? or string_or_io.empty?
  if !encoding
    encoding = EncodingReader.detect_encoding(string_or_io)
  end
  read_memory(string_or_io, url, encoding, options.to_i)
end

def serialize options = {}


end
config.format.as_xml
node.serialize(:encoding => 'UTF-8') do |config|

or

node.serialize(:encoding => 'UTF-8', :save_with => FORMAT | AS_XML)

These two statements are equivalent:

block. See SaveOptions.
Serialize Node using +options+. Save options can also be set using a
###
def serialize options = {}
  options[:save_with] ||= XML::Node::SaveOptions::DEFAULT_HTML
  super
end

def title

no title tag.
Get the title string of this document. Return nil if there is
##
def title
  title = at('title') and title.inner_text
end

def title=(text)

element, the title is not set.
Set the title string of this document. If there is no head
##
def title=(text)
  unless title = at('title')
    head = at('head') or return nil
    title = Nokogiri::XML::Node.new('title', self)
    head << title
  end
  title.children = XML::Text.new(text, self)
end