2011-12-28 22:36:55 +00:00
|
|
|
#include "tinyxml2.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
using namespace tinyxml2;
|
|
|
|
|
|
|
|
int main( int argc, const char* argv )
|
|
|
|
{
|
2012-01-15 02:08:12 +00:00
|
|
|
#if 0
|
2011-12-31 22:58:18 +00:00
|
|
|
{
|
|
|
|
static const char* test = "<!--hello world-->";
|
2011-12-28 22:36:55 +00:00
|
|
|
|
2011-12-31 22:58:18 +00:00
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( test );
|
|
|
|
doc.Print( stdout );
|
|
|
|
}
|
|
|
|
{
|
2012-01-15 02:08:12 +00:00
|
|
|
static const char* test = "<!--hello world\n"
|
2012-01-19 01:43:40 +00:00
|
|
|
" line 2\r"
|
|
|
|
" line 3\r\n"
|
|
|
|
" line 4\n\r"
|
|
|
|
" line 5\r-->";
|
|
|
|
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( test );
|
|
|
|
doc.Print( stdout );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
{
|
2012-02-07 02:18:11 +00:00
|
|
|
static const char* test[] = { "<element />",
|
|
|
|
"<element></element>",
|
|
|
|
"<element><subelement/></element>",
|
|
|
|
"<element><subelement></subelement></element>",
|
|
|
|
"<element><subelement><subsub/></subelement></element>",
|
|
|
|
"<!--comment beside elements--><element><subelement></subelement></element>",
|
|
|
|
"<!--comment beside elements, this time with spaces--> \n <element> <subelement> \n </subelement> </element>",
|
|
|
|
"<element attrib1='foo' attrib2=\"bar\" ></element>",
|
|
|
|
"<element attrib1='foo' attrib2=\"bar\" ><subelement attrib3='yeehaa' /></element>",
|
|
|
|
"<element>Text inside element.</element>",
|
|
|
|
"<element><b></b></element>",
|
|
|
|
"<element>Text inside and <b>bolded</b> in the element.</element>",
|
|
|
|
"<outer><element>Text inside and <b>bolded</b> in the element.</element></outer>",
|
2012-01-26 01:44:30 +00:00
|
|
|
"<element>This & That.</element>",
|
2012-01-27 02:17:26 +00:00
|
|
|
"<element attrib='This<That' />",
|
2012-01-19 01:55:48 +00:00
|
|
|
0
|
|
|
|
};
|
2012-01-22 02:45:16 +00:00
|
|
|
for( int i=0; test[i]; ++i ) {
|
2012-01-19 01:55:48 +00:00
|
|
|
XMLDocument doc;
|
2012-01-22 02:45:16 +00:00
|
|
|
doc.Parse( test[i] );
|
2012-01-25 02:03:07 +00:00
|
|
|
doc.Print();
|
2012-01-23 19:42:06 +00:00
|
|
|
printf( "----------------------------------------------\n" );
|
2012-01-19 01:55:48 +00:00
|
|
|
}
|
2011-12-31 22:58:18 +00:00
|
|
|
}
|
2012-01-31 16:24:24 +00:00
|
|
|
{
|
|
|
|
static const char* test = "<element>Text before.</element>";
|
|
|
|
XMLDocument doc;
|
|
|
|
doc.Parse( test );
|
|
|
|
XMLElement* root = doc.FirstChildElement();
|
|
|
|
XMLElement* newElement = doc.NewElement( "Subelement" );
|
|
|
|
root->InsertEndChild( newElement );
|
|
|
|
doc.Print();
|
|
|
|
}
|
2012-02-06 16:41:24 +00:00
|
|
|
{
|
|
|
|
XMLDocument* doc = new XMLDocument();
|
|
|
|
static const char* test = "<element><sub/></element>";
|
|
|
|
doc->Parse( test );
|
|
|
|
delete doc;
|
|
|
|
}
|
2011-12-28 22:36:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|