1
0

xmltest.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "tinyxml2.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. using namespace tinyxml2;
  5. int main( int argc, const char* argv )
  6. {
  7. #if 0
  8. {
  9. static const char* test = "<!--hello world-->";
  10. XMLDocument doc;
  11. doc.Parse( test );
  12. doc.Print( stdout );
  13. }
  14. {
  15. static const char* test = "<!--hello world\n"
  16. " line 2\r"
  17. " line 3\r\n"
  18. " line 4\n\r"
  19. " line 5\r-->";
  20. XMLDocument doc;
  21. doc.Parse( test );
  22. doc.Print( stdout );
  23. }
  24. #endif
  25. {
  26. static const char* test[] = { "<!--single element-->",
  27. "<element />",
  28. "<element></element>",
  29. "<!--single sub-element-->",
  30. "<element><subelement/></element>",
  31. "<element><subelement></subelement></element>",
  32. "<!--comment beside elements--><element><subelement></subelement></element>",
  33. 0
  34. };
  35. for( int i=0; test[i]; ++i ) {
  36. XMLDocument doc;
  37. doc.Parse( test[i] );
  38. doc.Print( stdout );
  39. printf( "----------------------------------------------\n" );
  40. }
  41. }
  42. return 0;
  43. }