diff options
Diffstat (limited to 'Swiften/Serializer/XML')
-rw-r--r-- | Swiften/Serializer/XML/XMLElement.cpp | 7 | ||||
-rw-r--r-- | Swiften/Serializer/XML/XMLElement.h | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/Swiften/Serializer/XML/XMLElement.cpp b/Swiften/Serializer/XML/XMLElement.cpp index d88ff08..289ce31 100644 --- a/Swiften/Serializer/XML/XMLElement.cpp +++ b/Swiften/Serializer/XML/XMLElement.cpp @@ -7,14 +7,17 @@ #include "Swiften/Serializer/XML/XMLElement.h" #include "Swiften/Base/foreach.h" +#include "Swiften/Serializer/XML/XMLTextNode.h" namespace Swift { -XMLElement::XMLElement(const String& tag, const String& xmlns) : - tag_(tag) { +XMLElement::XMLElement(const String& tag, const String& xmlns, const String& text) : tag_(tag) { if (!xmlns.isEmpty()) { setAttribute("xmlns", xmlns); } + if (!text.isEmpty()) { + addNode(XMLTextNode::ref(new XMLTextNode(text))); + } } String XMLElement::serialize() { diff --git a/Swiften/Serializer/XML/XMLElement.h b/Swiften/Serializer/XML/XMLElement.h index cac29f1..b350344 100644 --- a/Swiften/Serializer/XML/XMLElement.h +++ b/Swiften/Serializer/XML/XMLElement.h @@ -19,7 +19,7 @@ namespace Swift { public: typedef boost::shared_ptr<XMLElement> ref; - XMLElement(const String& tag, const String& xmlns = ""); + XMLElement(const String& tag, const String& xmlns = "", const String& text = ""); void setAttribute(const String& attribute, const String& value); void addNode(boost::shared_ptr<XMLNode> node); |