Class | Nokogiri::XML::Document
In: | lib/nokogiri/ffi/xml/document.rb lib/nokogiri/xml/document.rb ext/nokogiri/html_document.c
Parent: | Node

Nokogiri::XML::Document wraps an xml document.

### Methods

decorate decorators document dup encoding encoding= fragment name namespaces new new parse read_io read_memory root root= slop! url validate

### External Aliases

serialize | -> | to_xml
serialize | -> | inner_html
dup | -> | clone

### Attributes

errors | [RW] | A list of Nokogiri::XML::SyntaxError found when parsing a document

### Public Class methods

new(version = default)

Create a new document with `version` (defaults to "1.0")

new(*args)
parse(string_or_io, url = nil, encoding = nil, options = ParseOptions::DEFAULT_XML) {|options if block_given?| ...}

Parse an XML file. `thing` may be a String, or any object that responds to read and close such as an IO, or StringIO. `url` is resource where this document is located. `encoding` is the encoding that should be used when processing the document. `options` is a number that sets options in the parser, such as Nokogiri::XML::ParseOptions::RECOVER. See the constants in Nokogiri::XML::ParseOptions.

read_io(io, url, encoding, options)

Create a new document from an IO object

read_memory(string, url, encoding, options)

Create a new document from a String

### Public Instance methods

decorate(node)

Apply any decorators to `node`

decorators(key)

Get the list of decorators given `key`

document()

A reference to `self`

dup

Copy this Document. An optional depth may be passed in, but it defaults to a deep copy. 0 is a shallow copy, 1 is a deep copy.

encoding

Get the encoding for this Document

encoding= encoding

Set the encoding string for this Document

fragment(tags)

Create a Nokogiri::XML::DocumentFragment from `tags`

name()

The name of this document. Always returns "document"

namespaces()

Get the hash of namespaces on the root Nokogiri::XML::Node

root

Get the root node for this document.

root=

Set the root element on this document

slop!()

Explore a document with shortcut methods.

url

Get the url name for this document.

validate()

Validate this Document against it‘s DTD. Returns a list of errors on the document or `nil` when there is no DTD.

[Validate]