AnewtXMLWriter Class Reference

Procedural-style class to write out XML documents. More...

List of all members.

Public Member Functions

 __construct ()
 Create a new XML writer instance.
Document-related methods
These methods should be used to start and end documents. Calls to AnewtXMLWriter::write_start_document() and AnewtXMLWriter::write_end_document() should appear at the start and the end of your code, respectively.

 write_start_document ()
 Write the start of the document.
 write_end_document ()
 Write the end of the document.
 set_document_type ($doctype)
 Set the document type for the generated document.
 set_encoding ($encoding)
 Set the encoding for the generated document.
 set_content_type ($content_type)
 Set the content type for the generated document.
 set_standalone ($standalone)
 Set whether the generated document is standalone.
 get_document ()
 Return the AnewtXMLDomDocument instance this AnewtXMLWriter uses.
Element methods
Methods for writing elements to the document.

 write_start_element ($name, $attributes=null)
 Write the start of an element.
 write_end_element ($name=null)
 Write the end of an element.
 write_element_text ($name, $data, $attributes=null)
 Write element with textual data.
 write_element_raw ($name, $data, $attributes=null)
 Write element with raw data.
Attribute methods
Methods to write attributes to the currently open element.

 write_attribute ($name, $value)
 Write an attribute to the currently open element.
 write_attributes ($attributes)
 Write multiple attributes to the currently open element.
Textual data methods
Methods to write textual data to the document.

 write_text ($data)
 Write textual to the currently open element.
 write_raw ($data)
 Write raw data to the currently open element.
Miscellaneous writer methods
Various methods to write data to the document.

 write_comment ($data)
 Write a comment node to the document.
Output methods
Methods to produce output.

 render ()
 Render this document to a string.
 flush ()
 Flush output to the browser.
 flush_to_file ($filename)
 Flush output to a file.

Private Attributes

 $_document = null
 The document used in this AnewtXMLWriter instance.
 $_current_element = null
 Reference to the current element.


Detailed Description

Procedural-style class to write out XML documents.

This class can be used to write out XML documents with a simple procedural interface, allowing you to build output documents in a linear way. The basic usage pattern is:

Note that this class operates completely using in-memory DOM tree representations. It is not suitable to write very large XML documents to disk, but for relatively small XML documents it should be good enough.

Definition at line 35 of file writer.lib.php.


Member Function Documentation

AnewtXMLWriter::write_end_document (  ) 

Write the end of the document.

After calling this method, no further data can be written to this AnewtXMLWriter instance.

Definition at line 84 of file writer.lib.php.

AnewtXMLWriter::set_document_type ( doctype  ) 

Set the document type for the generated document.

Parameters:
$doctype The document type as string, or null to unset.
See also:
AnewtXMLDomDocument::set_document_type

Definition at line 101 of file writer.lib.php.

AnewtXMLWriter::set_encoding ( encoding  ) 

Set the encoding for the generated document.

Parameters:
$encoding The encoding as string, or null to unset.
See also:
AnewtXMLDomDocument::set_encoding

Definition at line 114 of file writer.lib.php.

AnewtXMLWriter::set_content_type ( content_type  ) 

Set the content type for the generated document.

Parameters:
$content_type The content type as string.
See also:
AnewtXMLDomDocument::set_content_type

Definition at line 127 of file writer.lib.php.

AnewtXMLWriter::set_standalone ( standalone  ) 

Set whether the generated document is standalone.

Parameters:
$standalone Boolean or null to unset.
See also:
AnewtXMLDomDocument::set_standalone

Definition at line 140 of file writer.lib.php.

AnewtXMLWriter::get_document (  ) 

Return the AnewtXMLDomDocument instance this AnewtXMLWriter uses.

This method can be used to retrieve the generated document. This method is only supposed to be called after a call to AnewtXMLWriter::write_end_document(). Usually you don't need this method, since the AnewtXMLWriter::render() and AnewtXMLWriter::flush() methods can take care of rendering the document properly.

Returns:
An AnewtXMLDomDocument instance.

Definition at line 157 of file writer.lib.php.

AnewtXMLWriter::write_start_element ( name,
attributes = null 
)

Write the start of an element.

Parameters:
$name The tag name for the element.
$attributes Associative array with initial attribute values for this element (optional). This parameter is for convenience only; you can always set attributes later using write_attribute.

Definition at line 182 of file writer.lib.php.

AnewtXMLWriter::write_end_element ( name = null  ) 

Write the end of an element.

Parameters:
$name The tag name of the element to end (optional). This value is not strictly needed, but if specified it is tested against the currently open element, triggering an assertion error if the wrong elements was open. This is mainly helpful to make sure your code is correct and you don't close elements you did not expect to close.

Definition at line 211 of file writer.lib.php.

AnewtXMLWriter::write_element_text ( name,
data,
attributes = null 
)

Write element with textual data.

This method opens a new element, writes the text and ends the element again.

Parameters:
$name The tag name for the element to write.
$data The textual data for this element.
$attributes Associative array with initial attribute values for this element (optional). This parameter is for convenience only; you can always set attributes later using write_attribute.
See also:
write_text

write_element_raw

AnewtXMLDomText

Definition at line 250 of file writer.lib.php.

AnewtXMLWriter::write_element_raw ( name,
data,
attributes = null 
)

Write element with raw data.

This method opens a new element, writes the raw data and ends the element again.

Parameters:
$name The tag name for the element to write.
$data The textual data for this element.
$attributes Associative array with initial attribute values for this element (optional). This parameter is for convenience only; you can always set attributes later using write_attribute.
See also:
write_raw

write_element_text

AnewtXMLDomRaw

Definition at line 279 of file writer.lib.php.

AnewtXMLWriter::write_attribute ( name,
value 
)

Write an attribute to the currently open element.

Parameters:
$name The name of attribute for which to set the value.
$value The value of the attribute.
See also:
write_attributes

Definition at line 307 of file writer.lib.php.

AnewtXMLWriter::write_attributes ( attributes  ) 

Write multiple attributes to the currently open element.

Parameters:
$attributes Associative array with attribute named and values.
See also:
write_attribute

Definition at line 323 of file writer.lib.php.

AnewtXMLWriter::write_text ( data  ) 

Write textual to the currently open element.

Parameters:
$data The textual data for this element.
See also:
write_element_text

write_raw

Definition at line 350 of file writer.lib.php.

AnewtXMLWriter::write_raw ( data  ) 

Write raw data to the currently open element.

Parameters:
$data The raw data for this element.
See also:
write_element_raw

write_text

Definition at line 365 of file writer.lib.php.

AnewtXMLWriter::write_comment ( data  ) 

Write a comment node to the document.

Parameters:
$data The comment text to write.

Definition at line 385 of file writer.lib.php.

AnewtXMLWriter::render (  ) 

Render this document to a string.

Returns:
Rendered string with XML data.
See also:
flush

AnewtXMLDomDocument::render

Definition at line 408 of file writer.lib.php.

AnewtXMLWriter::flush (  ) 

Flush output to the browser.

This method renders the document and outputs it to the browser with the correct headers.

See also:
set_content_type

render

flush_to_file

AnewtXMLDomDocument::flush

Definition at line 428 of file writer.lib.php.

AnewtXMLWriter::flush_to_file ( filename  ) 

Flush output to a file.

This method renders the document and outputs it to the specified file.

Parameters:
$filename The filename to write the output to.
See also:
flush

Definition at line 446 of file writer.lib.php.


Member Data Documentation

AnewtXMLWriter::$_document = null [private]

The document used in this AnewtXMLWriter instance.

See also:
get_document

Definition at line 42 of file writer.lib.php.

AnewtXMLWriter::$_current_element = null [private]

Reference to the current element.

This points to the variable to which subsequent calls to the write methods will add child nodes, attributes or textual content.

Definition at line 50 of file writer.lib.php.


The documentation for this class was generated from the following file:

Generated on Sun Aug 2 22:54:38 2009 for Anewt by  doxygen 1.5.9