Represents a full XML document, including PIs, a doctype, etc. A Document
has a single child that can be accessed by root(). Note that if you want to
have an XML declaration written for a document you create, you must add
one; REXML documents do not write a default declaration for you. See
|DECLARATION| and |write|.
| Public Methods |
| << |
Alias for #add
|
| add |
We override this, because XMLDecls and DocTypes must go at the start of the
document
|
| add_element |
|
| clone |
Should be obvious
|
| doctype |
@return the DocType child of the document, if one exists, and nil
otherwise.
|
| encoding |
@return the XMLDecl encoding of this document as a String. If no XMLDecl
has been set, returns the default encoding.
|
| expanded_name |
According to the XML spec, a root node has no expanded name
|
| name |
Alias for #expanded_name
|
| new |
Constructor @param source if supplied, must be a Document, String, or IO.
Documents have their context and Element attributes cloned. Strings are
expected to be valid XML documents. IOs are expected to be sources of valid
XML documents. @param context if supplied, contains the context of the
document; this should be a Hash.
|
| node_type |
|
| parse_stream |
|
| root |
@return the root Element of the document, or nil if this document has no
children.
|
| stand_alone? |
@return the XMLDecl standalone value of this document as a String. If no
XMLDecl has been set, returns the default setting.
|
| version |
@return the XMLDecl version of this document as a String. If no XMLDecl has
been set, returns the default version.
|
| write |
Write the XML tree out, optionally with indent. This writes out the entire
XML document, including XML declarations, doctype declarations, and
processing instructions (if any are given).
|
| xml_decl |
@return the XMLDecl of this document; if no XMLDecl has been set, the
default declaration is returned.
|
<code/>and<pre/>for code samples.