A wrapper for QXmlStreamWriter. More...
Public Member Functions | |
| void | writeAttribute (String aName, String aValue) |
| Writes an attribute with name and value. More... | |
| void | writeBytes (ByteArray aData) |
| Writes characters with name and binary data converted to text by Base64. More... | |
| void | writeBytesElement (String aName, ByteArray aData) |
| Writes a text element with name and binary data converted to text by Base64. More... | |
| void | writeCDATA (String aText) |
| Writes text as CDATA section. More... | |
| void | writeCharacters (String aText) |
| Writes text. More... | |
| void | writeDTD (String aDtd) |
| Writes a DTD section. More... | |
| void | writeEmptyElement (String aName) |
| Writes an empty element with name. More... | |
| void | writeEndDocument () |
| Writes a document end, and closes the file in case the file constructor was used. | |
| void | writeEndElement () |
| Writes a element end and closes the currently open element. | |
| void | writeStartDocument (String aVersion=undefined) |
| Writes a document start with the XML version number version. More... | |
| void | writeStartElement (String aName) |
| Writes a start element. More... | |
| void | writeTextElement (String aName, String aText) |
| Writes a text element with name and text. More... | |
| XmlWriter () | |
| Constructor to create the XML in memory. More... | |
| XmlWriter (String aFileName) | |
| Constructor to write directly in a file. More... | |
Properties | |
| Boolean | autoFormatting |
| The auto-formatting flag of the writer. More... | |
| String | autoFormattingIndent |
| Autoformat indentation level. More... | |
| String | string |
| The created XML as string. More... | |
A wrapper for QXmlStreamWriter.
Example usage:
| bps::XmlWriter::XmlWriter | ( | ) |
Constructor to create the XML in memory.
Get the data with property string at the end.
| bps::XmlWriter::XmlWriter | ( | String | aFileName | ) |
Constructor to write directly in a file.
| aFileName | The file name to write the XML. |
Writes an attribute with name and value.
This function can only be called after writeStartElement() before any content is written, or after writeEmptyElement().
| [in] | aName | The qualified attribute name. |
| [in] | aValue | The attribute value. |
| void bps::XmlWriter::writeBytes | ( | ByteArray | aData | ) |
Writes characters with name and binary data converted to text by Base64.
The characters '<', '&', and double quote are escaped as entity references "<", "&", and """. To avoid the forbidden sequence "]]>", ">" is also escaped as ">".
| [in] | aData | The binary data to write, for example a BLOB from the database. |
| void bps::XmlWriter::writeBytesElement | ( | String | aName, |
| ByteArray | aData | ||
| ) |
Writes a text element with name and binary data converted to text by Base64.
| [in] | aName | The qualified attribute name. |
| [in] | aData | The binary data to write, for example a BLOB from the database. |
| void bps::XmlWriter::writeCDATA | ( | String | aText | ) |
Writes text as CDATA section.
If text contains the forbidden character sequence "]]>", it is split into different CDATA sections. This function mainly exists for completeness. Normally you should not need use it, because writeCharacters() automatically escapes all non-content characters.
| [in] | aText | The text to write. |
| void bps::XmlWriter::writeCharacters | ( | String | aText | ) |
Writes text.
The characters '<', '&', and double quote are escaped as entity references "<", "&", and """. To avoid the forbidden sequence "]]>", ">" is also escaped as ">".
| [in] | aText | The text to write. |
| void bps::XmlWriter::writeDTD | ( | String | aDtd | ) |
Writes a DTD section.
| [in] | aDtd | Represents the entire doctypedecl production from the XML 1.0 specification. |
| void bps::XmlWriter::writeEmptyElement | ( | String | aName | ) |
Writes an empty element with name.
Subsequent calls to writeAttribute() will add attributes to this element.
| [in] | aName | The qualified element name. |
| void bps::XmlWriter::writeStartDocument | ( | String | aVersion = undefined | ) |
Writes a document start with the XML version number version.
When aVersion is omitted, "1.0" will be used.
| [in] | aVersion | The version string. |
| void bps::XmlWriter::writeStartElement | ( | String | aName | ) |
Writes a start element.
Subsequent calls to writeAttribute() will add attributes to this element.
| [in] | aName | The qualified element name. |
Writes a text element with name and text.
This is a convenience function equivalent to:
| [in] | aName | The qualified attribute name. |
| [in] | aText | The text to write. |
|
readwrite |
The auto-formatting flag of the writer.
Controls whether or not the writer automatically formats the generated XML data. If enabled, the writer automatically adds line-breaks and indentation to empty sections between elements (ignorable whitespace). The main purpose of auto-formatting is to split the data into several lines, and to increase readability for a human reader.
The indentation depth can be controlled through the autoFormattingIndent property.
By default, auto-formatting is disabled.
|
readwrite |
Autoformat indentation level.
The number of spaces or tabs used for indentation when auto-formatting is enabled. Positive numbers indicate spaces, negative numbers tabs.
The default indentation is 4.
|
read |
The created XML as string.
Only when using the default constructor, when using the file constructor this property always returns an empty string.