Qt 4.8
Public Functions | Properties | List of all members
QXmlStreamWriter Class Reference

The QXmlStreamWriter class provides an XML writer with a simple streaming API. More...

#include <qxmlstream.h>

Public Functions

bool autoFormatting () const
 This property controls whether or not the stream writer automatically formats the generated XML data. More...
 
int autoFormattingIndent () const
 the number of spaces or tabs used for indentation when auto-formatting is enabled. More...
 
QTextCodeccodec () const
 Returns the codec that is currently assigned to the stream. More...
 
QIODevicedevice () const
 Returns the current device associated with the QXmlStreamWriter, or 0 if no device has been assigned. More...
 
bool hasError () const
 Returns true if the stream failed to write to the underlying device; otherwise returns false. More...
 
 QXmlStreamWriter ()
 Constructs a stream writer. More...
 
 QXmlStreamWriter (QIODevice *device)
 Constructs a stream writer that writes into device;. More...
 
 QXmlStreamWriter (QByteArray *array)
 Constructs a stream writer that writes into array. More...
 
 QXmlStreamWriter (QString *string)
 Constructs a stream writer that writes into string. More...
 
void setAutoFormatting (bool)
 
void setAutoFormattingIndent (int spacesOrTabs)
 
void setCodec (QTextCodec *codec)
 Sets the codec for this stream to codec. More...
 
void setCodec (const char *codecName)
 Sets the codec for this stream to the QTextCodec for the encoding specified by codecName. More...
 
void setDevice (QIODevice *device)
 Sets the current device to device. More...
 
void writeAttribute (const QString &qualifiedName, const QString &value)
 Writes an attribute with qualifiedName and value. More...
 
void writeAttribute (const QString &namespaceUri, const QString &name, const QString &value)
 Writes an attribute with name and value, prefixed for the specified namespaceUri. More...
 
void writeAttribute (const QXmlStreamAttribute &attribute)
 Writes the attribute. More...
 
void writeAttributes (const QXmlStreamAttributes &attributes)
 Writes the attribute vector attributes. More...
 
void writeCDATA (const QString &text)
 Writes text as CDATA section. More...
 
void writeCharacters (const QString &text)
 Writes text. More...
 
void writeComment (const QString &text)
 Writes text as XML comment, where text must not contain the forbidden sequence "--" or end with "-". More...
 
void writeCurrentToken (const QXmlStreamReader &reader)
 Writes the current state of the reader. More...
 
void writeDefaultNamespace (const QString &namespaceUri)
 Writes a default namespace declaration for namespaceUri. More...
 
void writeDTD (const QString &dtd)
 Writes a DTD section. More...
 
void writeEmptyElement (const QString &qualifiedName)
 Writes an empty element with qualified name qualifiedName. More...
 
void writeEmptyElement (const QString &namespaceUri, const QString &name)
 Writes an empty element with name, prefixed for the specified namespaceUri. More...
 
void writeEndDocument ()
 Closes all remaining open start elements and writes a newline. More...
 
void writeEndElement ()
 Closes the previous start element. More...
 
void writeEntityReference (const QString &name)
 Writes the entity reference name to the stream, as "&\a{name};". More...
 
void writeNamespace (const QString &namespaceUri, const QString &prefix=QString())
 Writes a namespace declaration for namespaceUri with prefix. More...
 
void writeProcessingInstruction (const QString &target, const QString &data=QString())
 Writes an XML processing instruction with target and data, where data must not contain the sequence "?>". More...
 
void writeStartDocument ()
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes a document start with XML version number "1.0". More...
 
void writeStartDocument (const QString &version)
 Writes a document start with the XML version number version. More...
 
void writeStartDocument (const QString &version, bool standalone)
 Writes a document start with the XML version number version and a standalone attribute standalone. More...
 
void writeStartElement (const QString &qualifiedName)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes a start element with qualifiedName. More...
 
void writeStartElement (const QString &namespaceUri, const QString &name)
 Writes a start element with name, prefixed for the specified namespaceUri. More...
 
void writeTextElement (const QString &qualifiedName, const QString &text)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Writes a text element with qualifiedName and text. More...
 
void writeTextElement (const QString &namespaceUri, const QString &name, const QString &text)
 Writes a text element with name, prefixed for the specified namespaceUri, and text. More...
 
 ~QXmlStreamWriter ()
 Destructor. More...
 

Properties

QScopedPointer< QXmlStreamWriterPrivated_ptr
 

Detailed Description

The QXmlStreamWriter class provides an XML writer with a simple streaming API.

Since
4.3
Note
This class or function is reentrant.

QXmlStreamWriter is the counterpart to QXmlStreamReader for writing XML. Like its related class, it operates on a QIODevice specified with setDevice(). The API is simple and straightforward: for every XML token or event you want to write, the writer provides a specialized function.

You start a document with writeStartDocument() and end it with writeEndDocument(). This will implicitly close all remaining open tags.

Element tags are opened with writeStartElement() followed by writeAttribute() or writeAttributes(), element content, and then writeEndElement(). A shorter form writeEmptyElement() can be used to write empty elements, followed by writeAttributes().

Element content consists of either characters, entity references or nested elements. It is written with writeCharacters(), which also takes care of escaping all forbidden characters and character sequences, writeEntityReference(), or subsequent calls to writeStartElement(). A convenience method writeTextElement() can be used for writing terminal elements that contain nothing but text.

The following abridged code snippet shows the basic use of the class to write formatted XML with indentation:

stream.setAutoFormatting(true);
stream.writeStartDocument();

...

stream.writeStartElement("bookmark");
stream.writeAttribute("href", "http://qt.nokia.com/");
stream.writeTextElement("title", "Qt Home");
stream.writeEndElement(); // bookmark

...

stream.writeEndDocument();

QXmlStreamWriter takes care of prefixing namespaces, all you have to do is specify the namespaceUri when writing elements or attributes. If you must conform to certain prefixes, you can force the writer to use them by declaring the namespaces manually with either writeNamespace() or writeDefaultNamespace(). Alternatively, you can bypass the stream writer's namespace support and use overloaded methods that take a qualified name instead. The namespace http://www.w3.org/XML/1998/namespace is implicit and mapped to the prefix xml.

The stream writer can automatically format the generated XML data by adding line-breaks and indentation to empty sections between elements, making the XML data more readable for humans and easier to work with for most source code management systems. The feature can be turned on with the autoFormatting property, and customized with the autoFormattingIndent property.

Other functions are writeCDATA(), writeComment(), writeProcessingInstruction(), and writeDTD(). Chaining of XML streams is supported with writeCurrentToken().

By default, QXmlStreamWriter encodes XML in UTF-8. Different encodings can be enforced using setCodec().

If an error occurs while writing to the underlying device, hasError() starts returning true and subsequent writes are ignored.

The QXmlStream Bookmarks Example illustrates how to use a stream writer to write an XML bookmark file (XBEL) that was previously read in by a QXmlStreamReader.

Definition at line 416 of file qxmlstream.h.

Constructors and Destructors

◆ QXmlStreamWriter() [1/4]

QXmlStreamWriter::QXmlStreamWriter ( )

Constructs a stream writer.

See also
setDevice()

Definition at line 3368 of file qxmlstream.cpp.

3369  : d_ptr(new QXmlStreamWriterPrivate(this))
3370 {
3371 }
QScopedPointer< QXmlStreamWriterPrivate > d_ptr
Definition: qxmlstream.h:482

◆ QXmlStreamWriter() [2/4]

QXmlStreamWriter::QXmlStreamWriter ( QIODevice device)

Constructs a stream writer that writes into device;.

Definition at line 3376 of file qxmlstream.cpp.

3377  : d_ptr(new QXmlStreamWriterPrivate(this))
3378 {
3380  d->device = device;
3381 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482
QIODevice * device() const
Returns the current device associated with the QXmlStreamWriter, or 0 if no device has been assigned...
QScopedPointer< QXmlStreamWriterPrivate > d_ptr
Definition: qxmlstream.h:482

◆ QXmlStreamWriter() [3/4]

QXmlStreamWriter::QXmlStreamWriter ( QByteArray array)

Constructs a stream writer that writes into array.

This is the same as creating an xml writer that operates on a QBuffer device which in turn operates on array.

Definition at line 3387 of file qxmlstream.cpp.

3388  : d_ptr(new QXmlStreamWriterPrivate(this))
3389 {
3391  d->device = new QBuffer(array);
3392  d->device->open(QIODevice::WriteOnly);
3393  d->deleteDevice = true;
3394 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
The QBuffer class provides a QIODevice interface for a QByteArray.
Definition: qbuffer.h:57
#define Q_D(Class)
Definition: qglobal.h:2482
QScopedPointer< QXmlStreamWriterPrivate > d_ptr
Definition: qxmlstream.h:482

◆ QXmlStreamWriter() [4/4]

QXmlStreamWriter::QXmlStreamWriter ( QString string)

Constructs a stream writer that writes into string.

Definition at line 3399 of file qxmlstream.cpp.

3400  : d_ptr(new QXmlStreamWriterPrivate(this))
3401 {
3403  d->stringDevice = string;
3404 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482
QScopedPointer< QXmlStreamWriterPrivate > d_ptr
Definition: qxmlstream.h:482

◆ ~QXmlStreamWriter()

QXmlStreamWriter::~QXmlStreamWriter ( )

Destructor.

Definition at line 3409 of file qxmlstream.cpp.

3410 {
3411 }

Functions

◆ autoFormatting()

bool QXmlStreamWriter::autoFormatting ( ) const

This property controls whether or not the stream writer automatically formats the generated XML data.

Since
4.4 the auto-formatting flag of the stream writer

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.

Since
4.4

Returns true if auto formattting is enabled, otherwise false.

Definition at line 3532 of file qxmlstream.cpp.

Referenced by QXmlStreamWriterPrivate::writeStartElement().

3533 {
3534  Q_D(const QXmlStreamWriter);
3535  return d->autoFormatting;
3536 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482

◆ autoFormattingIndent()

int QXmlStreamWriter::autoFormattingIndent ( ) const

the number of spaces or tabs used for indentation when auto-formatting is enabled.

Positive numbers indicate spaces, negative numbers tabs.

Since
4.4

The default indentation is 4.

See also
autoFormatting

Definition at line 3561 of file qxmlstream.cpp.

3562 {
3563  Q_D(const QXmlStreamWriter);
3564  return d->autoFormattingIndent.count(' ') - d->autoFormattingIndent.count('\t');
3565 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482

◆ codec()

QTextCodec * QXmlStreamWriter::codec ( ) const

Returns the codec that is currently assigned to the stream.

See also
setCodec()

Definition at line 3487 of file qxmlstream.cpp.

Referenced by setCodec().

3488 {
3489  Q_D(const QXmlStreamWriter);
3490  return d->codec;
3491 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482

◆ device()

QIODevice * QXmlStreamWriter::device ( ) const

Returns the current device associated with the QXmlStreamWriter, or 0 if no device has been assigned.

See also
setDevice()

Definition at line 3439 of file qxmlstream.cpp.

Referenced by QXmlStreamWriter(), and setDevice().

3440 {
3441  Q_D(const QXmlStreamWriter);
3442  return d->device;
3443 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482

◆ hasError()

bool QXmlStreamWriter::hasError ( ) const

Returns true if the stream failed to write to the underlying device; otherwise returns false.

Since
4.8

The error status is never reset. Writes happening after the error occurred are ignored, even if the error condition is cleared.

Definition at line 3579 of file qxmlstream.cpp.

3580 {
3581  Q_D(const QXmlStreamWriter);
3582  return d->hasError;
3583 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setAutoFormatting()

void QXmlStreamWriter::setAutoFormatting ( bool  enable)
Since
4.4

Enables auto formatting if enable is true, otherwise disables it.

The default value is false.

Definition at line 3521 of file qxmlstream.cpp.

Referenced by QTextOdfWriter::writeAll().

3522 {
3524  d->autoFormatting = enable;
3525 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setAutoFormattingIndent()

void QXmlStreamWriter::setAutoFormattingIndent ( int  spacesOrTabs)

Definition at line 3555 of file qxmlstream.cpp.

Referenced by QTextOdfWriter::writeAll().

3556 {
3558  d->autoFormattingIndent = QByteArray(qAbs(spacesOrTabs), spacesOrTabs >= 0 ? ' ' : '\t');
3559 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setCodec() [1/2]

void QXmlStreamWriter::setCodec ( QTextCodec codec)

Sets the codec for this stream to codec.

The codec is used for encoding any data that is written. By default, QXmlStreamWriter uses UTF-8.

The encoding information is stored in the initial xml tag which gets written when you call writeStartDocument(). Call this function before calling writeStartDocument().

See also
codec()

Definition at line 3458 of file qxmlstream.cpp.

Referenced by setCodec(), and QTextOdfWriter::writeAll().

3459 {
3461  if (codec) {
3462  d->codec = codec;
3463  delete d->encoder;
3464  d->encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8
3465  d->checkIfASCIICompatibleCodec();
3466  }
3467 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482
QTextEncoder * makeEncoder() const
Creates a QTextEncoder which stores enough state to encode chunks of Unicode data as char * data...
QTextCodec * codec() const
Returns the codec that is currently assigned to the stream.

◆ setCodec() [2/2]

void QXmlStreamWriter::setCodec ( const char *  codecName)

Sets the codec for this stream to the QTextCodec for the encoding specified by codecName.

Common values for codecName include "ISO 8859-1", "UTF-8", and "UTF-16". If the encoding isn't recognized, nothing happens.

See also
QTextCodec::codecForName()

Definition at line 3477 of file qxmlstream.cpp.

3478 {
3479  setCodec(QTextCodec::codecForName(codecName));
3480 }
void setCodec(QTextCodec *codec)
Sets the codec for this stream to codec.
static QTextCodec * codecForName(const QByteArray &name)
Searches all installed QTextCodec objects and returns the one which best matches name; the match is c...

◆ setDevice()

void QXmlStreamWriter::setDevice ( QIODevice device)

Sets the current device to device.

If you want the stream to write into a QByteArray, you can create a QBuffer device.

See also
device()

Definition at line 3420 of file qxmlstream.cpp.

3421 {
3423  if (device == d->device)
3424  return;
3425  d->stringDevice = 0;
3426  if (d->deleteDevice) {
3427  delete d->device;
3428  d->deleteDevice = false;
3429  }
3430  d->device = device;
3431 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482
QIODevice * device() const
Returns the current device associated with the QXmlStreamWriter, or 0 if no device has been assigned...

◆ writeAttribute() [1/3]

void QXmlStreamWriter::writeAttribute ( const QString qualifiedName,
const QString value 
)

Writes an attribute with qualifiedName and value.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This function can only be called after writeStartElement() before any content is written, or after writeEmptyElement().

Definition at line 3596 of file qxmlstream.cpp.

Referenced by QTextOdfWriter::writeAll(), writeAttribute(), writeAttributes(), QTextOdfWriter::writeBlock(), QTextOdfWriter::writeBlockFormat(), QTextOdfWriter::writeCharacterFormat(), QTextOdfWriter::writeFrame(), QTextOdfWriter::writeFrameFormat(), QTextOdfWriter::writeInlineCharacter(), QTextOdfWriter::writeListFormat(), and QTextOdfWriter::writeTableCellFormat().

3597 {
3599  Q_ASSERT(d->inStartElement);
3600  Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1);
3601  d->write(" ");
3602  d->write(qualifiedName);
3603  d->write("=\"");
3604  d->writeEscaped(value, true);
3605  d->write("\"");
3606 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
int count() const
Definition: qstring.h:103
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ writeAttribute() [2/3]

void QXmlStreamWriter::writeAttribute ( const QString namespaceUri,
const QString name,
const QString value 
)

Writes an attribute with name and value, prefixed for the specified namespaceUri.

If the namespace has not been declared yet, QXmlStreamWriter will generate a namespace declaration for it.

This function can only be called after writeStartElement() before any content is written, or after writeEmptyElement().

Definition at line 3616 of file qxmlstream.cpp.

3617 {
3619  Q_ASSERT(d->inStartElement);
3620  Q_ASSERT(!name.contains(QLatin1Char(':')));
3621  QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->findNamespace(namespaceUri, true, true);
3622  d->write(" ");
3623  if (!namespaceDeclaration.prefix.isEmpty()) {
3624  d->write(namespaceDeclaration.prefix);
3625  d->write(":");
3626  }
3627  d->write(name);
3628  d->write("=\"");
3629  d->writeEscaped(value, true);
3630  d->write("\"");
3631 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ writeAttribute() [3/3]

void QXmlStreamWriter::writeAttribute ( const QXmlStreamAttribute attribute)

Writes the attribute.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This function can only be called after writeStartElement() before any content is written, or after writeEmptyElement().

Definition at line 3644 of file qxmlstream.cpp.

3645 {
3646  if (attribute.namespaceUri().isEmpty())
3647  writeAttribute(attribute.qualifiedName().toString(),
3648  attribute.value().toString());
3649  else
3650  writeAttribute(attribute.namespaceUri().toString(),
3651  attribute.name().toString(),
3652  attribute.value().toString());
3653 }
QString toString() const
Returns a copy of the string reference as a QString object.
Definition: qstring.cpp:8653
QStringRef value() const
Returns the attribute&#39;s value.
Definition: qxmlstream.h:156
QStringRef qualifiedName() const
Returns the attribute&#39;s qualified name.
Definition: qxmlstream.h:150
void writeAttribute(const QString &qualifiedName, const QString &value)
Writes an attribute with qualifiedName and value.
bool isEmpty() const
Returns true if the string reference has no characters; otherwise returns false.
Definition: qstring.h:1169
QStringRef name() const
Returns the attribute&#39;s local name.
Definition: qxmlstream.h:149
QStringRef namespaceUri() const
Returns the attribute&#39;s resolved namespaceUri, or an empty string reference if the attribute does not...
Definition: qxmlstream.h:148

◆ writeAttributes()

void QXmlStreamWriter::writeAttributes ( const QXmlStreamAttributes attributes)

Writes the attribute vector attributes.

If a namespace referenced in an attribute not been declared yet, QXmlStreamWriter will generate a namespace declaration for it.

This function can only be called after writeStartElement() before any content is written, or after writeEmptyElement().

See also
writeAttribute(), writeNamespace()

Definition at line 3665 of file qxmlstream.cpp.

Referenced by writeCurrentToken().

3666 {
3668  Q_ASSERT(d->inStartElement);
3669  Q_UNUSED(d);
3670  for (int i = 0; i < attributes.size(); ++i)
3671  writeAttribute(attributes.at(i));
3672 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
void writeAttribute(const QString &qualifiedName, const QString &value)
Writes an attribute with qualifiedName and value.
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ writeCDATA()

void QXmlStreamWriter::writeCDATA ( const QString text)

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.

Definition at line 3683 of file qxmlstream.cpp.

Referenced by writeCurrentToken().

3684 {
3686  d->finishStartElement();
3687  QString copy(text);
3688  copy.replace(QLatin1String("]]>"), QLatin1String("]]]]><![CDATA[>"));
3689  d->write("<![CDATA[");
3690  d->write(copy);
3691  d->write("]]>");
3692 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482

◆ writeCharacters()

void QXmlStreamWriter::writeCharacters ( const QString text)

Writes text.

The characters "<", "&", and "\"" are escaped as entity references "<", "&, and "&quot;". To avoid the forbidden sequence "]]>", ">" is also escaped as "&gt;".

See also
writeEntityReference()

Definition at line 3701 of file qxmlstream.cpp.

Referenced by QTextOdfWriter::writeBlock(), writeCurrentToken(), and writeTextElement().

3702 {
3704  d->finishStartElement();
3705  d->writeEscaped(text);
3706 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482

◆ writeComment()

void QXmlStreamWriter::writeComment ( const QString text)

Writes text as XML comment, where text must not contain the forbidden sequence "--" or end with "-".

Note that XML does not provide any way to escape "-" in a comment.

Definition at line 3713 of file qxmlstream.cpp.

Referenced by writeCurrentToken().

3714 {
3716  Q_ASSERT(!text.contains(QLatin1String("--")) && !text.endsWith(QLatin1Char('-')));
3717  if (!d->finishStartElement(false) && d->autoFormatting)
3718  d->indent(d->tagStack.size());
3719  d->write("<!--");
3720  d->write(text);
3721  d->write("-->");
3722  d->inStartElement = d->lastWasStartElement = false;
3723 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ writeCurrentToken()

void QXmlStreamWriter::writeCurrentToken ( const QXmlStreamReader reader)

Writes the current state of the reader.

All possible valid states are supported.

The purpose of this function is to support chained processing of XML data.

See also
QXmlStreamReader::tokenType()

Definition at line 4071 of file qxmlstream.cpp.

4072 {
4073  switch (reader.tokenType()) {
4075  break;
4078  break;
4080  writeEndDocument();
4081  break;
4083  QXmlStreamNamespaceDeclarations namespaceDeclarations = reader.namespaceDeclarations();
4084  for (int i = 0; i < namespaceDeclarations.size(); ++i) {
4085  const QXmlStreamNamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.at(i);
4086  writeNamespace(namespaceDeclaration.namespaceUri().toString(),
4087  namespaceDeclaration.prefix().toString());
4088  }
4089  writeStartElement(reader.namespaceUri().toString(), reader.name().toString());
4090  writeAttributes(reader.attributes());
4091  } break;
4093  writeEndElement();
4094  break;
4096  if (reader.isCDATA())
4097  writeCDATA(reader.text().toString());
4098  else
4099  writeCharacters(reader.text().toString());
4100  break;
4102  writeComment(reader.text().toString());
4103  break;
4104  case QXmlStreamReader::DTD:
4105  writeDTD(reader.text().toString());
4106  break;
4108  writeEntityReference(reader.name().toString());
4109  break;
4112  reader.processingInstructionData().toString());
4113  break;
4114  default:
4116  qWarning("QXmlStreamWriter: writeCurrentToken() with invalid state.");
4117  break;
4118  }
4119 }
QString toString() const
Returns a copy of the string reference as a QString object.
Definition: qstring.cpp:8653
bool isCDATA() const
Returns true if the reader reports characters that stem from a CDATA section; otherwise returns false...
void writeEndDocument()
Closes all remaining open start elements and writes a newline.
QStringRef name() const
Returns the local name of a StartElement, EndElement, or an EntityReference.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void writeDTD(const QString &dtd)
Writes a DTD section.
void writeEntityReference(const QString &name)
Writes the entity reference name to the stream, as "&\a{name};".
void writeCDATA(const QString &text)
Writes text as CDATA section.
QStringRef namespaceUri() const
Returns the namespaceUri of a StartElement or EndElement.
TokenType tokenType() const
Returns the type of the current token.
Definition: qxmlstream.cpp:656
void writeNamespace(const QString &namespaceUri, const QString &prefix=QString())
Writes a namespace declaration for namespaceUri with prefix.
Q_CORE_EXPORT void qWarning(const char *,...)
QStringRef namespaceUri() const
Returns the namespaceUri.
Definition: qxmlstream.h:216
QStringRef prefix() const
Returns the prefix.
Definition: qxmlstream.h:215
void writeCharacters(const QString &text)
Writes text.
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
The QXmlStreamNamespaceDeclaration class represents a namespace declaration.
Definition: qxmlstream.h:204
void writeStartDocument()
This is an overloaded member function, provided for convenience. It differs from the above function o...
void writeEndElement()
Closes the previous start element.
QXmlStreamNamespaceDeclarations namespaceDeclarations() const
If the state() is StartElement , this function returns the element&#39;s namespace declarations.
QStringRef processingInstructionData() const
Returns the data of a ProcessingInstruction.
void writeProcessingInstruction(const QString &target, const QString &data=QString())
Writes an XML processing instruction with target and data, where data must not contain the sequence "...
QStringRef processingInstructionTarget() const
Returns the target of a ProcessingInstruction.
QStringRef text() const
Returns the text of Characters , Comment , DTD , or EntityReference.
void writeComment(const QString &text)
Writes text as XML comment, where text must not contain the forbidden sequence "--" or end with "-"...
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QXmlStreamAttributes attributes() const
Returns the attributes of a StartElement.
void writeAttributes(const QXmlStreamAttributes &attributes)
Writes the attribute vector attributes.
void writeStartElement(const QString &qualifiedName)
This is an overloaded member function, provided for convenience. It differs from the above function o...

◆ writeDefaultNamespace()

void QXmlStreamWriter::writeDefaultNamespace ( const QString namespaceUri)

Writes a default namespace declaration for namespaceUri.

If writeStartElement() or writeEmptyElement() was called, the declaration applies to the current element; otherwise it applies to the next child element.

Note that the namespaces http://www.w3.org/XML/1998/namespace (bound to xmlns) and http://www.w3.org/2000/xmlns/ (bound to xml) by definition cannot be declared as default.

Definition at line 3915 of file qxmlstream.cpp.

3916 {
3918  Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/XML/1998/namespace"));
3919  Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/2000/xmlns/"));
3920  QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push();
3921  namespaceDeclaration.prefix.clear();
3922  namespaceDeclaration.namespaceUri = d->addToStringStorage(namespaceUri);
3923  if (d->inStartElement)
3924  d->writeNamespaceDeclaration(namespaceDeclaration);
3925 }
double d
Definition: qnumeric_p.h:62
void clear()
Clears the contents of the string reference by making it null and empty.
Definition: qstring.h:1167
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482

◆ writeDTD()

void QXmlStreamWriter::writeDTD ( const QString dtd)

Writes a DTD section.

The dtd represents the entire doctypedecl production from the XML 1.0 specification.

Definition at line 3729 of file qxmlstream.cpp.

Referenced by writeCurrentToken().

3730 {
3732  d->finishStartElement();
3733  if (d->autoFormatting)
3734  d->write("\n");
3735  d->write(dtd);
3736  if (d->autoFormatting)
3737  d->write("\n");
3738 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482

◆ writeEmptyElement() [1/2]

void QXmlStreamWriter::writeEmptyElement ( const QString qualifiedName)

Writes an empty element with qualified name qualifiedName.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Subsequent calls to writeAttribute() will add attributes to this element.

Definition at line 3749 of file qxmlstream.cpp.

Referenced by QTextOdfWriter::writeBlock(), QTextOdfWriter::writeBlockFormat(), QTextOdfWriter::writeCharacterFormat(), QTextOdfWriter::writeFrame(), QTextOdfWriter::writeFrameFormat(), QTextOdfWriter::writeListFormat(), and QTextOdfWriter::writeTableCellFormat().

3750 {
3752  Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1);
3753  d->writeStartElement(QString(), qualifiedName);
3754  d->inEmptyElement = true;
3755 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
int count() const
Definition: qstring.h:103
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ writeEmptyElement() [2/2]

void QXmlStreamWriter::writeEmptyElement ( const QString namespaceUri,
const QString name 
)

Writes an empty element with name, prefixed for the specified namespaceUri.

If the namespace has not been declared, QXmlStreamWriter will generate a namespace declaration for it. Subsequent calls to writeAttribute() will add attributes to this element.

See also
writeNamespace()

Definition at line 3765 of file qxmlstream.cpp.

3766 {
3768  Q_ASSERT(!name.contains(QLatin1Char(':')));
3769  d->writeStartElement(namespaceUri, name);
3770  d->inEmptyElement = true;
3771 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ writeEndDocument()

void QXmlStreamWriter::writeEndDocument ( )

Closes all remaining open start elements and writes a newline.

See also
writeStartDocument()

Definition at line 3812 of file qxmlstream.cpp.

Referenced by QTextOdfWriter::writeAll(), and writeCurrentToken().

3813 {
3815  while (d->tagStack.size())
3816  writeEndElement();
3817  d->write("\n");
3818 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482
void writeEndElement()
Closes the previous start element.

◆ writeEndElement()

void QXmlStreamWriter::writeEndElement ( )

Closes the previous start element.

See also
writeStartElement()

Definition at line 3825 of file qxmlstream.cpp.

Referenced by QTextOdfWriter::writeAll(), QTextOdfWriter::writeBlock(), QTextOdfWriter::writeBlockFormat(), QTextOdfWriter::writeCharacterFormat(), writeCurrentToken(), writeEndDocument(), QTextOdfWriter::writeFormats(), QTextOdfWriter::writeFrame(), QTextOdfWriter::writeFrameFormat(), QTextOdfWriter::writeInlineCharacter(), QTextOdfWriter::writeListFormat(), QTextOdfWriter::writeTableCellFormat(), and writeTextElement().

3826 {
3828  if (d->tagStack.isEmpty())
3829  return;
3830 
3831  // shortcut: if nothing was written, close as empty tag
3832  if (d->inStartElement && !d->inEmptyElement) {
3833  d->write("/>");
3834  d->lastWasStartElement = d->inStartElement = false;
3835  QXmlStreamWriterPrivate::Tag &tag = d->tagStack_pop();
3836  d->lastNamespaceDeclaration = tag.namespaceDeclarationsSize;
3837  return;
3838  }
3839 
3840  if (!d->finishStartElement(false) && !d->lastWasStartElement && d->autoFormatting)
3841  d->indent(d->tagStack.size()-1);
3842  if (d->tagStack.isEmpty())
3843  return;
3844  d->lastWasStartElement = false;
3845  QXmlStreamWriterPrivate::Tag &tag = d->tagStack_pop();
3846  d->lastNamespaceDeclaration = tag.namespaceDeclarationsSize;
3847  d->write("</");
3848  if (!tag.namespaceDeclaration.prefix.isEmpty()) {
3849  d->write(tag.namespaceDeclaration.prefix);
3850  d->write(":");
3851  }
3852  d->write(tag.name);
3853  d->write(">");
3854 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482
bool isEmpty() const
Returns true if the string reference has no characters; otherwise returns false.
Definition: qstring.h:1169
NamespaceDeclaration namespaceDeclaration
Definition: qxmlstream_p.h:690

◆ writeEntityReference()

void QXmlStreamWriter::writeEntityReference ( const QString name)

Writes the entity reference name to the stream, as "&\a{name};".

Definition at line 3861 of file qxmlstream.cpp.

Referenced by writeCurrentToken().

3862 {
3864  d->finishStartElement();
3865  d->write("&");
3866  d->write(name);
3867  d->write(";");
3868 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482

◆ writeNamespace()

void QXmlStreamWriter::writeNamespace ( const QString namespaceUri,
const QString prefix = QString() 
)

Writes a namespace declaration for namespaceUri with prefix.

If prefix is empty, QXmlStreamWriter assigns a unique prefix consisting of the letter 'n' followed by a number.

If writeStartElement() or writeEmptyElement() was called, the declaration applies to the current element; otherwise it applies to the next child element.

Note that the prefix xml is both predefined and reserved for http://www.w3.org/XML/1998/namespace, which in turn cannot be bound to any other prefix. The prefix xmlns and its URI http://www.w3.org/2000/xmlns/ are used for the namespace mechanism itself and thus completely forbidden in declarations.

Definition at line 3886 of file qxmlstream.cpp.

Referenced by QTextOdfWriter::writeAll(), and writeCurrentToken().

3887 {
3889  Q_ASSERT(!namespaceUri.isEmpty());
3890  Q_ASSERT(prefix != QLatin1String("xmlns"));
3891  if (prefix.isEmpty()) {
3892  d->findNamespace(namespaceUri, d->inStartElement);
3893  } else {
3894  Q_ASSERT(!((prefix == QLatin1String("xml")) ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace"))));
3895  Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/2000/xmlns/"));
3896  QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push();
3897  namespaceDeclaration.prefix = d->addToStringStorage(prefix);
3898  namespaceDeclaration.namespaceUri = d->addToStringStorage(namespaceUri);
3899  if (d->inStartElement)
3900  d->writeNamespaceDeclaration(namespaceDeclaration);
3901  }
3902 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704

◆ writeProcessingInstruction()

void QXmlStreamWriter::writeProcessingInstruction ( const QString target,
const QString data = QString() 
)

Writes an XML processing instruction with target and data, where data must not contain the sequence "?>".

Definition at line 3932 of file qxmlstream.cpp.

Referenced by writeCurrentToken().

3933 {
3935  Q_ASSERT(!data.contains(QLatin1String("?>")));
3936  if (!d->finishStartElement(false) && d->autoFormatting)
3937  d->indent(d->tagStack.size());
3938  d->write("<?");
3939  d->write(target);
3940  if (!data.isNull()) {
3941  d->write(" ");
3942  d->write(data);
3943  }
3944  d->write("?>");
3945 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505

◆ writeStartDocument() [1/3]

void QXmlStreamWriter::writeStartDocument ( )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes a document start with XML version number "1.0".

This also writes the encoding information.

See also
writeEndDocument(), setCodec()
Since
4.5

Definition at line 3957 of file qxmlstream.cpp.

Referenced by QTextOdfWriter::writeAll(), and writeCurrentToken().

3958 {
3960 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void writeStartDocument()
This is an overloaded member function, provided for convenience. It differs from the above function o...

◆ writeStartDocument() [2/3]

void QXmlStreamWriter::writeStartDocument ( const QString version)

Writes a document start with the XML version number version.

See also
writeEndDocument()

Definition at line 3968 of file qxmlstream.cpp.

3969 {
3971  d->finishStartElement(false);
3972  d->write("<?xml version=\"");
3973  d->write(version);
3974  if (d->device) { // stringDevice does not get any encoding
3975  d->write("\" encoding=\"");
3976 #ifdef QT_NO_TEXTCODEC
3977  d->write("iso-8859-1");
3978 #else
3979  d->write(d->codec->name().constData(), d->codec->name().length());
3980 #endif
3981  }
3982  d->write("\"?>");
3983 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482

◆ writeStartDocument() [3/3]

void QXmlStreamWriter::writeStartDocument ( const QString version,
bool  standalone 
)

Writes a document start with the XML version number version and a standalone attribute standalone.

See also
writeEndDocument()
Since
4.5

Definition at line 3991 of file qxmlstream.cpp.

3992 {
3994  d->finishStartElement(false);
3995  d->write("<?xml version=\"");
3996  d->write(version);
3997  if (d->device) { // stringDevice does not get any encoding
3998  d->write("\" encoding=\"");
3999 #ifdef QT_NO_TEXTCODEC
4000  d->write("iso-8859-1");
4001 #else
4002  d->write(d->codec->name().constData(), d->codec->name().length());
4003 #endif
4004  }
4005  if (standalone)
4006  d->write("\" standalone=\"yes\"?>");
4007  else
4008  d->write("\" standalone=\"no\"?>");
4009 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_D(Class)
Definition: qglobal.h:2482

◆ writeStartElement() [1/2]

void QXmlStreamWriter::writeStartElement ( const QString qualifiedName)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes a start element with qualifiedName.

Subsequent calls to writeAttribute() will add attributes to this element.

See also
writeEndElement(), writeEmptyElement()

Definition at line 4019 of file qxmlstream.cpp.

Referenced by QTextOdfWriter::writeAll(), QTextOdfWriter::writeBlock(), QTextOdfWriter::writeBlockFormat(), QTextOdfWriter::writeCharacterFormat(), writeCurrentToken(), QTextOdfWriter::writeFormats(), QTextOdfWriter::writeFrame(), QTextOdfWriter::writeFrameFormat(), QTextOdfWriter::writeInlineCharacter(), QTextOdfWriter::writeListFormat(), QTextOdfWriter::writeTableCellFormat(), and writeTextElement().

4020 {
4022  Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1);
4023  d->writeStartElement(QString(), qualifiedName);
4024 }
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
int count() const
Definition: qstring.h:103
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ writeStartElement() [2/2]

void QXmlStreamWriter::writeStartElement ( const QString namespaceUri,
const QString name 
)

Writes a start element with name, prefixed for the specified namespaceUri.

If the namespace has not been declared yet, QXmlStreamWriter will generate a namespace declaration for it. Subsequent calls to writeAttribute() will add attributes to this element.

See also
writeNamespace(), writeEndElement(), writeEmptyElement()

Definition at line 4035 of file qxmlstream.cpp.

4036 {
4038  Q_ASSERT(!name.contains(QLatin1Char(':')));
4039  d->writeStartElement(namespaceUri, name);
4040 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
double d
Definition: qnumeric_p.h:62
The QXmlStreamWriter class provides an XML writer with a simple streaming API.
Definition: qxmlstream.h:416
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ writeTextElement() [1/2]

void QXmlStreamWriter::writeTextElement ( const QString qualifiedName,
const QString text 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Writes a text element with qualifiedName and text.

This is a convenience function equivalent to:

Definition at line 3782 of file qxmlstream.cpp.

3783 {
3784  writeStartElement(qualifiedName);
3785  writeCharacters(text);
3786  writeEndElement();
3787 }
void writeCharacters(const QString &text)
Writes text.
void writeEndElement()
Closes the previous start element.
void writeStartElement(const QString &qualifiedName)
This is an overloaded member function, provided for convenience. It differs from the above function o...

◆ writeTextElement() [2/2]

void QXmlStreamWriter::writeTextElement ( const QString namespaceUri,
const QString name,
const QString text 
)

Writes a text element with name, prefixed for the specified namespaceUri, and text.

If the namespace has not been declared, QXmlStreamWriter will generate a namespace declaration for it.

This is a convenience function equivalent to:

Definition at line 3799 of file qxmlstream.cpp.

3800 {
3801  writeStartElement(namespaceUri, name);
3802  writeCharacters(text);
3803  writeEndElement();
3804 }
void writeCharacters(const QString &text)
Writes text.
void writeEndElement()
Closes the previous start element.
void writeStartElement(const QString &qualifiedName)
This is an overloaded member function, provided for convenience. It differs from the above function o...

Properties

◆ d_ptr

QScopedPointer<QXmlStreamWriterPrivate> QXmlStreamWriter::d_ptr
private

Definition at line 482 of file qxmlstream.h.


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