aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-07-08 12:31:24 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-07-08 12:31:24 +0000
commitf4367130d868e9a4e9abcbfaecde350c9230c218 (patch)
tree22860e627ea23ff93943322581523eb321009938 /source
parent43fa2896657f339949f4372423bab1f2ac3949f7 (diff)
downloadqxmpp-f4367130d868e9a4e9abcbfaecde350c9230c218.tar.gz
improve QXmppElement serialisation
* don't call writeCharacterData if a node has no value (allows for collapsed elements) * write "xmlns" attribute first
Diffstat (limited to 'source')
-rw-r--r--source/QXmppElement.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/source/QXmppElement.cpp b/source/QXmppElement.cpp
index 028770c0..09fa40e4 100644
--- a/source/QXmppElement.cpp
+++ b/source/QXmppElement.cpp
@@ -211,9 +211,13 @@ void QXmppElement::toXml(QXmlStreamWriter *writer) const
return;
writer->writeStartElement(d->name);
+ if (d->attributes.contains("xmlns"))
+ helperToXmlAddAttribute(writer, "xmlns", d->attributes.value("xmlns"));
foreach (const QString &attr, d->attributes.keys())
- helperToXmlAddAttribute(writer, attr, d->attributes.value(attr));
- writer->writeCharacters(d->value);
+ if (attr != "xmlns")
+ helperToXmlAddAttribute(writer, attr, d->attributes.value(attr));
+ if (!d->value.isEmpty())
+ writer->writeCharacters(d->value);
foreach (const QXmppElement &child, d->children)
child.toXml(writer);
writer->writeEndElement();