class LibXML::XML::Document

def self.document(value)

document - A preparsed document.

Parameters:

Creates a new document based on the specified document.

XML::Document.document(document) -> XML::Document
call-seq:
def self.document(value)
  Parser.document(value).parse
end

def self.file(path, encoding: nil, options: nil)

by using Bitwise OR (|).
XML::Parser::Options. Mutliple options can be combined
options - Parser options. Valid values are the constants defined on
are the encoding constants defined on XML::Encoding.
encoding - The document encoding, defaults to nil. Valid values
path - Path to file

Parameters:

Creates a new document from the specified file or uri.

options: XML::Parser::Options::NOENT) -> XML::Document
XML::Document.file(path, encoding: XML::Encoding::UTF_8,
XML::Document.file(path) -> XML::Document
call-seq:
def self.file(path, encoding: nil, options: nil)
  Parser.file(path, encoding: encoding, options: options).parse
end

def self.io(io, base_uri: nil, encoding: nil, options: nil)

by using Bitwise OR (|).
XML::Parser::Options. Mutliple options can be combined
options - Parser options. Valid values are the constants defined on
are the encoding constants defined on XML::Encoding.
encoding - The document encoding, defaults to nil. Valid values
base_uri - The base url for the parsed document.
io - io object that contains the xml to parser

Parameters:

Creates a new document from the specified io object.

:base_uri="http://libxml.org") -> XML::Document
:options => XML::Parser::Options::NOENT
XML::Document.io(io, :encoding => XML::Encoding::UTF_8,
XML::Document.io(io) -> XML::Document
call-seq:
def self.io(io, base_uri: nil, encoding: nil, options: nil)
  Parser.io(io, base_uri: base_uri, encoding: encoding, options: options).parse
end

def self.string(value, base_uri: nil, encoding: nil, options: nil)

by using Bitwise OR (|).
XML::Parser::Options. Mutliple options can be combined
options - Parser options. Valid values are the constants defined on
are the encoding constants defined on XML::Encoding.
encoding - The document encoding, defaults to nil. Valid values
base_uri - The base url for the parsed document.
string - String to parse

Parameters:

Creates a new document from the specified string.

base_uri: "http://libxml.org") -> XML::Document
options: XML::Parser::Options::NOENT
XML::Document.string(string, encoding: XML::Encoding::UTF_8,
XML::Document.string(string) -> XML::Document
call-seq:
def self.string(value, base_uri: nil, encoding: nil, options: nil)
  Parser.string(value, base_uri: base_uri, encoding: encoding, options: options).parse
end

def context(nslist = nil)

Namespaces is an optional array of XML::NS objects

document.context(namespaces=nil) -> XPath::Context
call-seq:

Returns a new XML::XPathContext for the document.
def context(nslist = nil)
  context = XPath::Context.new(self)
  context.node = self.root
  context.register_namespaces_from_node(self.root)
  context.register_namespaces(nslist) if nslist
  context
end

def debug_dump

def debug_dump
  warn('Document#debug_dump is deprecated.  Use Document#debug instead.')
  self.debug
end

def debug_dump_head

def debug_dump_head
  warn('Document#debug_dump_head is deprecated.  Use Document#debug instead.')
  self.debug
end

def debug_format_dump

def debug_format_dump
  warn('Document#debug_format_dump is deprecated.  Use Document#to_s instead.')
  self.to_s
end

def docbook_doc?

Specifies if this is an docbook node
def docbook_doc?
  node_type == XML::Node::DOCB_DOCUMENT_NODE
end

def document?

Specifies if this is an document node
def document?
  node_type == XML::Node::DOCUMENT_NODE
end

def dump

def dump
  warn('Document#dump is deprecated.  Use Document#to_s instead.')
  self.to_s
end

def find(xpath, nslist = nil)

# nodes = nil # GC.start
end
... do stuff ...
nodes.each do |node|
nodes = doc.find('/header')

To avoid this, use the following (non-ruby like) coding style:
list, which will cause a segmentation fault.
As a result, the associated document may be freed before the node
(see http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/17700).
in which objects are freed
However, if the program exits, Ruby does not guarantee the order
happen automatically via Ruby's mark and sweep garbage collector.
its associated document. In a running Ruby program this will
IMPORTANT - The returned XML::Node::Set must be freed before

document.find('/foo', 'xlink:http://www.w3.org/1999/xlink')

* namespaces - An optional list of namespaces (see XML::XPath for information).
* xpath - The xpath expression as a string
Parameters:

document.find(xpath, nslist=nil) -> XML::XPath::Object
call-seq:

to the XML::XPath documentation.
information about working with namespaces, please refer
optionally using the specified namespace. For more
Return the nodes matching the specified xpath expression,
def find(xpath, nslist = nil)
  self.context(nslist).find(xpath)
end

def find_first(xpath, nslist = nil)

for XML::Document#find.
For more information, please refer to the documentation
Return the first node matching the specified xpath expression.
def find_first(xpath, nslist = nil)
  find(xpath, nslist).first
end

def format_dump

def format_dump
  warn('Document#format_dump is deprecated.  Use Document#to_s instead.')
  self.to_s
end

def html_doc?

Specifies if this is an html node
def html_doc?
  node_type == XML::Node::HTML_DOCUMENT_NODE
end

def node_type_name

Returns this node's type name
def node_type_name
  case node_type
  when XML::Node::DOCUMENT_NODE
    'document_xml'
  when XML::Node::DOCB_DOCUMENT_NODE
    'document_docbook'
  when XML::Node::HTML_DOCUMENT_NODE
    'document_html'
  else
    raise(UnknownType, "Unknown node type: %n", node.node_type);
  end
end

def reader

def reader
  warn('Document#reader is deprecated.  Use XML::Reader.document(self) instead.')
  XML::Reader.document(self)
end