Hello. I've downloaded the TinyXML package and am using MS Visual Studio 2005 Express for development.
I'm sending you this message to tell that I'm having serious trouble using TinyXML: my users.xml file looks like this:
<user name="0" pass="0" />
<user name="1" pass="1" />
<user name="2" pass="2" />
<user name="3" pass="3" />
I've actually created it using TinyXML so think understood how the creation works (but will have questions about it later). And my code to "start reading it" is
int n_of_users = 0;
TiXmlDocument doc( "users.xml" );
TiXmlHandle docHandle( &doc );
TiXmlElement* element = docHandle.FirstChild().Element();
while( NULL != element )
{
element = NULL; // To be changed later...
n_of_users++;
}
Hello. I've downloaded the TinyXML package and am using MS Visual Studio 2005 Express for development.
I'm sending you this message to tell that I'm having serious trouble using TinyXML: my users.xml file looks like this:
<user name="0" pass="0" />
<user name="1" pass="1" />
<user name="2" pass="2" />
<user name="3" pass="3" />
I've actually created it using TinyXML so think understood how the creation works (but will have questions about it later). And my code to "start reading it" is
int n_of_users = 0;
TiXmlDocument doc( "users.xml" );
TiXmlHandle docHandle( &doc );
TiXmlElement* element = docHandle.FirstChild().Element();
while( NULL != element )
{
element = NULL; // To be changed later...
n_of_users++;
}
char str[ 55 ];
sprintf( str, "%d", n_of_users );
MessageBox( 0, str, str, 0 );
Problem: docHandle.FirstChild().Element() is always NULL! What am I doing wrong?
Cheers
S. Ali Tokmen
http://ali.tokmen.com
More interesting: the code to read the XML has been replaced with:
TiXmlDocument doc( "users.xml" );
TiXmlHandle docHandle( &doc );
TiXmlNode* element = docHandle.Node();
if( element->NoChildren() )
{
MessageBox( 0, "a", "a", 0 );
}
And, NoChildren() is always true!
What's happening?
S. Ali Tokmen
http://ali.tokmen.com
OK, it's solved... :)
S. Ali Tokmen
http://ali.tokmen.com
I think its something else, but:
1) Your XML should have a toplevel group, e.g.
<users>
<user name="0" pass="0" />
<user name="1" pass="1" />
<user name="2" pass="2" />
<user name="3" pass="3" />
</users>
2) your iteration code is odd. Have you read the docs and http://software.ellerton.net/tinyxml.html ?
HTH
Ellers