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. | |
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.
| 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.
| $doctype | The document type as string, or null to unset. |
Definition at line 101 of file writer.lib.php.
| AnewtXMLWriter::set_encoding | ( | $ | encoding | ) |
Set the encoding for the generated document.
| $encoding | The encoding as string, or null to unset. |
Definition at line 114 of file writer.lib.php.
| AnewtXMLWriter::set_content_type | ( | $ | content_type | ) |
Set the content type for the generated document.
| $content_type | The content type as string. |
Definition at line 127 of file writer.lib.php.
| AnewtXMLWriter::set_standalone | ( | $ | standalone | ) |
Set whether the generated document is standalone.
| $standalone | Boolean or null to unset. |
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.
Definition at line 157 of file writer.lib.php.
| AnewtXMLWriter::write_start_element | ( | $ | name, | |
| $ | attributes = null | |||
| ) |
Write the start of an element.
| $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.
| $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.
| $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. |
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.
| $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. |
Definition at line 279 of file writer.lib.php.
| AnewtXMLWriter::write_attribute | ( | $ | name, | |
| $ | value | |||
| ) |
Write an attribute to the currently open element.
| $name | The name of attribute for which to set the value. | |
| $value | The value of the attribute. |
Definition at line 307 of file writer.lib.php.
| AnewtXMLWriter::write_attributes | ( | $ | attributes | ) |
Write multiple attributes to the currently open element.
| $attributes | Associative array with attribute named and values. |
Definition at line 323 of file writer.lib.php.
| AnewtXMLWriter::write_text | ( | $ | data | ) |
Write textual to the currently open element.
| $data | The textual data for this element. |
Definition at line 350 of file writer.lib.php.
| AnewtXMLWriter::write_raw | ( | $ | data | ) |
Write raw data to the currently open element.
| $data | The raw data for this element. |
Definition at line 365 of file writer.lib.php.
| AnewtXMLWriter::write_comment | ( | $ | data | ) |
Write a comment node to the document.
| $data | The comment text to write. |
Definition at line 385 of file writer.lib.php.
| AnewtXMLWriter::render | ( | ) |
Render this document to a string.
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.
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.
| $filename | The filename to write the output to. |
Definition at line 446 of file writer.lib.php.
AnewtXMLWriter::$_document = null [private] |
The document used in this AnewtXMLWriter instance.
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.
1.5.9