add convenience methods
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 0467d17..f260513 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -1962,41 +1962,34 @@
}
-XMLElement* XMLElement::PushNewChildElement(const char* name)
+XMLElement* XMLElement::InsertNewChildElement(const char* name)
{
- XMLElement* element = _document->NewElement(name);
- // by construction, the new element has the same Document, so this
- // call will always succeed
- InsertEndChild(element);
- return element;
+ XMLElement* node = _document->NewElement(name);
+ return InsertEndChild(node) ? node : 0;
}
-XMLComment* XMLElement::PushNewChildComment(const char* comment)
+XMLComment* XMLElement::InsertNewComment(const char* comment)
{
- XMLComment* element = _document->NewComment(comment);
- InsertEndChild(element);
- return element;
+ XMLComment* node = _document->NewComment(comment);
+ return InsertEndChild(node) ? node : 0;
}
-XMLText* XMLElement::PushNewChildText(const char* text)
+XMLText* XMLElement::InsertNewText(const char* text)
{
- XMLText* element = _document->NewText(text);
- InsertEndChild(element);
- return element;
+ XMLText* node = _document->NewText(text);
+ return InsertEndChild(node) ? node : 0;
}
-XMLDeclaration* XMLElement::PushNewChildDeclaration(const char* text)
+XMLDeclaration* XMLElement::InsertNewDeclaration(const char* text)
{
- XMLDeclaration* element = _document->NewDeclaration(text);
- InsertEndChild(element);
- return element;
+ XMLDeclaration* node = _document->NewDeclaration(text);
+ return InsertEndChild(node) ? node : 0;
}
-XMLUnknown* XMLElement::PushNewUnknown(const char* text)
+XMLUnknown* XMLElement::InsertNewUnknown(const char* text)
{
- XMLUnknown* element = _document->NewUnknown(text);
- InsertEndChild(element);
- return element;
+ XMLUnknown* node = _document->NewUnknown(text);
+ return InsertEndChild(node) ? node : 0;
}