diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 5880557..95075a5 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1260,6 +1260,16 @@ const char* XMLElement::GetText() const } +void XMLElement::SetText( const char* inText ) +{ + if ( FirstChild() ) + FirstChild()->SetValue( inText ); + else { + XMLText* theText = GetDocument()->NewText( inText ); + InsertFirstChild( theText ); + } +} + XMLError XMLElement::QueryIntText( int* ival ) const { if ( FirstChild() && FirstChild()->ToText() ) { diff --git a/tinyxml2.h b/tinyxml2.h index 086c282..3ae1c32 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -116,9 +116,9 @@ inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... ) #define TIXML_SSCANF sscanf #endif -static const int TIXML2_MAJOR_VERSION = 1; -static const int TIXML2_MINOR_VERSION = 0; -static const int TIXML2_PATCH_VERSION = 13; +static const int TIXML2_MAJOR_VERSION = 1; +static const int TIXML2_MINOR_VERSION = 0; +static const int TIXML2_PATCH_VERSION = 13; namespace tinyxml2 { @@ -1369,6 +1369,8 @@ public: */ const char* GetText() const; + void SetText( const char* inText ); + /** Convenience method to query the value of a child text node. This is probably best shown by example. Given you have a document is this form: