Write out exactly what we got in.
Returns the namespace URL, if defined, or nil otherwise
e = Element.new("el") e.add_namespace("ns", "http://url") e.add_attribute("ns:a", "b") e.add_attribute("nsx:a", "c") e.attribute("ns:a").namespace # => "http://url" e.attribute("nsx:a").namespace # => nil
This method always returns “” for no namespace attribute. Because the default namespace doesn’t apply to attribute names.
From www.w3.org/TR/xml-names/#uniqAttrs
> the default namespace does not apply to attribute names
e = REXML::Element.new("el") e.add_namespace("", "http://example.com/") e.namespace # => "http://example.com/" e.add_attribute("a", "b") e.attribute("a").namespace # => ""
Returns a copy of this attribute
Writes this attribute (EG, puts ‘key=“value”’ to the output)
Make a copy of this object
Examples
c = CData.new( "Some text" ) d = c.clone d.to_s # -> "Some text"
See the rexml/formatters package
Generates XML
output of this object
Where to write the string. Defaults to $stdout
The amount to indent this node by
Ignored
Ignored
Examples
c = CData.new( " Some text " ) c.write( $stdout ) #-> <![CDATA[ Some text ]]>
Where to write the string
An integer. If -1, no indenting will be used; otherwise, the indentation will be this number of spaces, and children will be indented an additional amount.
Ignored by this class. The contents of comments are never modified.
Needed for conformity to the child API, but not used by this class.
Where to write the string
An integer. If -1, no indentation will be used; otherwise, the indentation will be this number of spaces, and children will be indented an additional amount.
Ignored
Ignored
Should be obvious
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).
A controversial point is whether Document
should always write the XML
declaration (<?xml version=‘1.0’?>) whether or not one is given by the user (or source document). REXML
does not write one if one was not specified, because it adds unnecessary bandwidth to applications such as XML-RPC.
Accept Nth argument style and options Hash
style as argument. The recommended style is options Hash
style for one or more arguments case.
Examples
Document.new("<a><b/></a>").write output = "" Document.new("<a><b/></a>").write(output) output = "" Document.new("<a><b/></a>").write(:output => output, :indent => 2)
See also the classes in the rexml/formatters package for the proper way to change the default formatting of XML
output.
Examples
output = "" tr = Transitive.new tr.write(Document.new("<a><b/></a>"), output)
output an object which supports ‘<< string’; this is where the document will be written.
An integer. If -1, no indenting will be used; otherwise, the indentation will be twice this number of spaces, and children will be indented an additional amount. For a value of 3, every item will be indented 3 more levels, or 6 more spaces (2 * 3). Defaults to -1
If transitive is true and indent is >= 0, then the output will be pretty-printed in such a way that the added whitespace does not affect the absolute value of the document – that is, it leaves the value and number of Text
nodes in the document unchanged.
This hack inserts a space before the /> on empty tags to address a limitation of Internet Explorer. Defaults to false
Encoding
name as String
. Change output encoding to specified encoding instead of encoding in XML
declaration. Defaults to nil. It means encoding in XML
declaration is used.