blob: b624d9b0fdb406e1c81f5af6db3228b61e26bcbb [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 Thomason50adb4c2012-02-13 15:07:09 -080010#if 1
U-Lama\Lee4cee6112011-12-31 14:58:18 -080011 {
Lee Thomasonfde6a752012-01-14 18:08:12 -080012 static const char* test = "<!--hello world\n"
Lee Thomason8a5dfee2012-01-18 17:43:40 -080013 " line 2\r"
14 " line 3\r\n"
15 " line 4\n\r"
16 " line 5\r-->";
17
18 XMLDocument doc;
19 doc.Parse( test );
Lee Thomason50adb4c2012-02-13 15:07:09 -080020 doc.Print();
Lee Thomason8a5dfee2012-01-18 17:43:40 -080021 }
22#endif
Lee Thomason50adb4c2012-02-13 15:07:09 -080023#if 0
Lee Thomason8a5dfee2012-01-18 17:43:40 -080024 {
Lee Thomason43f59302012-02-06 18:18:11 -080025 static const char* test[] = { "<element />",
26 "<element></element>",
27 "<element><subelement/></element>",
28 "<element><subelement></subelement></element>",
29 "<element><subelement><subsub/></subelement></element>",
30 "<!--comment beside elements--><element><subelement></subelement></element>",
31 "<!--comment beside elements, this time with spaces--> \n <element> <subelement> \n </subelement> </element>",
32 "<element attrib1='foo' attrib2=\"bar\" ></element>",
33 "<element attrib1='foo' attrib2=\"bar\" ><subelement attrib3='yeehaa' /></element>",
34 "<element>Text inside element.</element>",
35 "<element><b></b></element>",
36 "<element>Text inside and <b>bolded</b> in the element.</element>",
37 "<outer><element>Text inside and <b>bolded</b> in the element.</element></outer>",
Lee Thomason8ee79892012-01-25 17:44:30 -080038 "<element>This &amp; That.</element>",
Lee Thomason18d68bd2012-01-26 18:17:26 -080039 "<element attrib='This&lt;That' />",
Lee Thomasondadcdfa2012-01-18 17:55:48 -080040 0
41 };
Lee Thomason6ee99fc2012-01-21 18:45:16 -080042 for( int i=0; test[i]; ++i ) {
Lee Thomasondadcdfa2012-01-18 17:55:48 -080043 XMLDocument doc;
Lee Thomason6ee99fc2012-01-21 18:45:16 -080044 doc.Parse( test[i] );
Lee Thomason5cae8972012-01-24 18:03:07 -080045 doc.Print();
Lee Thomasonec975ce2012-01-23 11:42:06 -080046 printf( "----------------------------------------------\n" );
Lee Thomasondadcdfa2012-01-18 17:55:48 -080047 }
U-Lama\Lee4cee6112011-12-31 14:58:18 -080048 }
Lee Thomason50adb4c2012-02-13 15:07:09 -080049#endif
50#if 1
Lee Thomason2c85a712012-01-31 08:24:24 -080051 {
52 static const char* test = "<element>Text before.</element>";
53 XMLDocument doc;
54 doc.Parse( test );
55 XMLElement* root = doc.FirstChildElement();
56 XMLElement* newElement = doc.NewElement( "Subelement" );
57 root->InsertEndChild( newElement );
58 doc.Print();
59 }
Lee Thomasond1983222012-02-06 08:41:24 -080060 {
61 XMLDocument* doc = new XMLDocument();
62 static const char* test = "<element><sub/></element>";
63 doc->Parse( test );
64 delete doc;
65 }
Lee Thomason56bdd022012-02-09 18:16:58 -080066#endif
U-Lama\Leee13c3e62011-12-28 14:36:55 -080067 return 0;
68}