Class

REXML::Formatters::Pretty

Inheritance
< REXML::Formatters::Default < Object

Pretty-prints an XML document. This destroys whitespace in text nodes and will insert carriage returns and indentations.

TODO: Add an option to print attributes on new lines

Attributes

Name Visibility R/W Description
compact public RW If compact is set to true, then the formatter will attempt to use as little space as possible
width public RW The width of a page. Used for formatting text

Methods

Class

Visibility Signature
public new ( indentation=2, ie_hack=false )

Instance

Visibility Signature
protected write_cdata ( node, output)
protected write_comment ( node, output)
protected write_document ( node, output )
protected write_element (node, output)
protected write_text ( node, output )

Class Method Detail

new( indentation=2, ie_hack=false )

Create a new pretty printer.

output:An object implementing ’<<(String)’, to which the output will be written.
indentation:An integer greater than 0. The indentation of each level will be this number of spaces. If this is < 1, the behavior of this object is undefined. Defaults to 2.
ie_hack:If true, the printer will insert whitespace before closing empty tags, thereby allowing Internet Explorer‘s feeble XML parser to function. Defaults to false.

Instance Method Detail

write_cdata( node, output)

write_comment( node, output)

write_document( node, output )

write_element(node, output)

write_text( node, output )