Hello, I'm trying to use TinyXML to read a XML and store some of it's values to a string array.
How would I do this?
So far this is my code: (note you can pretty much just skip to my int main() since everything else is good)
Code:
#define TIXML_USE_STL
#include "tinyxml.h"
#ifdef TIXML_USE_STL
#include <iostream>
#include <sstream>
using namespace std;
#else
#include <stdio.h>
#endif
#if defined( WIN32 ) && defined( TUNE )
#include <windows.h>
__int64 start;
__int64 end;
__int64 freq;
#endif
static int gPass = 0;
static int gFail = 0;
bool XmlTest (const char* testString, const char* expected, const char* found, bool noEcho = false)
{
bool pass = !strcmp( expected, found );
if ( pass )
printf ("[pass]");
else
printf ("[fail]");
if ( noEcho )
printf (" %s\n", testString);
else
printf (" %s [%s][%s]\n", testString, expected, found);
if ( pass )
++gPass;
else
++gFail;
return pass;
}
bool XmlTest( const char* testString, int expected, int found, bool noEcho = false )
{
bool pass = ( expected == found );
if ( pass )
printf ("[pass]");
else
printf ("[fail]");
if ( noEcho )
printf (" %s\n", testString);
else
printf (" %s [%d][%d]\n", testString, expected, found);
if ( pass )
++gPass;
else
++gFail;
return pass;
}
int main()
{
TiXmlDocument doc( "demotest.xml" );
TiXmlElement * element = new TiXmlElement( "Bold" );
doc.LinkEndChild( element );
cout << element; //i'm just doing cout for now so i can see that a word is stored and not some random bs.
system("PAUSE");
}
The out put it get is:
0x4a1098Press any key to continue...
my xml file looks like this
<?xml version="1.0" standalone="no" ?>
- <!--
Our to do list data -->
- <ToDo>
- <!--
Do I need a secure PDA? -->
- <Item priority="1" distance="close">
Go to the
<bold>Toy store!</bold>
</Item>
<Item priority="2" distance="none">Do bills</Item>
<Item priority="2" distance="far & back">Look for Evil Dinosaurs!</Item>
</ToDo>