blob: bef0216589d63498cace37d7b409fb344a63094e [file] [log] [blame]
U-Lama\Leee13c3e62011-12-28 14:36:55 -08001#include "tinyxml2.h"
2
3#include <stdio.h>
4#include <stdlib.h>
5
6using namespace tinyxml2;
7
8int main( int argc, const char* argv )
9{
Lee Thomasonfde6a752012-01-14 18:08:12 -080010#if 0
U-Lama\Lee4cee6112011-12-31 14:58:18 -080011 {
12 static const char* test = "<!--hello world-->";
U-Lama\Leee13c3e62011-12-28 14:36:55 -080013
U-Lama\Lee4cee6112011-12-31 14:58:18 -080014 XMLDocument doc;
15 doc.Parse( test );
16 doc.Print( stdout );
17 }
U-Lama\Lee4cee6112011-12-31 14:58:18 -080018 {
Lee Thomasonfde6a752012-01-14 18:08:12 -080019 static const char* test = "<!--hello world\n"
Lee Thomason8a5dfee2012-01-18 17:43:40 -080020 " line 2\r"
21 " line 3\r\n"
22 " line 4\n\r"
23 " line 5\r-->";
24
25 XMLDocument doc;
26 doc.Parse( test );
27 doc.Print( stdout );
28 }
29#endif
30 {
Lee Thomason5cae8972012-01-24 18:03:07 -080031 static const char* test[] = { //"<element />",
32 //"<element></element>",
33 //"<element><subelement/></element>",
34 //"<element><subelement></subelement></element>",
Lee Thomason8ee79892012-01-25 17:44:30 -080035 // "<element><subelement><subsub/></subelement></element>",
36 //"<!--comment beside elements--><element><subelement></subelement></element>",
Lee Thomason5cae8972012-01-24 18:03:07 -080037 //"<!--comment beside elements, this time with spaces--> \n <element> <subelement> \n </subelement> </element>",
Lee Thomason8ee79892012-01-25 17:44:30 -080038 //"<element attrib1='foo' attrib2=\"bar\" ></element>",
39 //"<element attrib1='foo' attrib2=\"bar\" ><subelement attrib3='yeehaa' /></element>",
Lee Thomason5cae8972012-01-24 18:03:07 -080040 //"<element>Text inside element.</element>",
41 //"<element><b></b></element>",
Lee Thomason8ee79892012-01-25 17:44:30 -080042 //"<element>Text inside and <b>bolded</b> in the element.</element>",
43 //"<outer><element>Text inside and <b>bolded</b> in the element.</element></outer>",
44 "<element>This &amp; That.</element>",
Lee Thomason18d68bd2012-01-26 18:17:26 -080045 "<element attrib='This&lt;That' />",
Lee Thomasondadcdfa2012-01-18 17:55:48 -080046 0
47 };
Lee Thomason6ee99fc2012-01-21 18:45:16 -080048 for( int i=0; test[i]; ++i ) {
Lee Thomasondadcdfa2012-01-18 17:55:48 -080049 XMLDocument doc;
Lee Thomason6ee99fc2012-01-21 18:45:16 -080050 doc.Parse( test[i] );
Lee Thomason5cae8972012-01-24 18:03:07 -080051 doc.Print();
Lee Thomasonec975ce2012-01-23 11:42:06 -080052 printf( "----------------------------------------------\n" );
Lee Thomasondadcdfa2012-01-18 17:55:48 -080053 }
U-Lama\Lee4cee6112011-12-31 14:58:18 -080054 }
Lee Thomason2c85a712012-01-31 08:24:24 -080055 {
56 static const char* test = "<element>Text before.</element>";
57 XMLDocument doc;
58 doc.Parse( test );
59 XMLElement* root = doc.FirstChildElement();
60 XMLElement* newElement = doc.NewElement( "Subelement" );
61 root->InsertEndChild( newElement );
62 doc.Print();
63 }
Lee Thomasond1983222012-02-06 08:41:24 -080064 {
65 XMLDocument* doc = new XMLDocument();
66 static const char* test = "<element><sub/></element>";
67 doc->Parse( test );
68 delete doc;
69 }
U-Lama\Leee13c3e62011-12-28 14:36:55 -080070 return 0;
71}