Sadly, i've spent the past fifteen hours trying to get TinyXML to do what I think should be a simple task.
Here's the code of what i'm doing:
if(Operation == OP_VERIFY_ACCOUNT)
{
const char *p1 = "xmlaccounts";
const char *p2 = ".xml";
char fi[255];
char test[255];
const char *docpass;
const char *v1 = mnGetStringC(RecvPacket, 0, true);
const char *v2 = mnGetStringC(RecvPacket, 0, true);
strcat(fi, p1);
strcat(fi, v1);
strcat(fi, p2);
dbPrint(fi);
TiXmlDocument doc(fi);
bool loadok = doc.LoadFile();
if (loadok == true)
{
//TiXmlText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText();
//doc.FirstChildElement( "element" )->Attribute( "attr" )
//docpass = doc.FirstChildElement( "password" )->Value( );
TiXmlHandle docHandle( &doc );
TiXmlElement *root = docHandle.FirstChildElement( "Account" ).Element();
TiXmlElement *item = root->FirstChildElement( "Password" );
docpass = item->Value();
//docpass = tHandle.Text()->Value();
//strcpy(test, docpass);
//dbPrint(test);
if (!strcmp(docpass, v2))
{
mnAddInt(SendPacket, OP_VERIFY_PASSED);
mnAddInt(SendPacket, nClient);
mnSendTCP(0, SendPacket, nClient, false, true);
dbPrintC("Client ");
dbPrintC(dbStr(nClient));
dbPrint(" Successfully Authed In");
} else if (strcmp(docpass,v2))
{
mnAddInt(SendPacket, OP_VERIFY_FAILED);
mnAddInt(SendPacket, nClient);
mnSendTCP(0, SendPacket, nClient, false, true);
dbPrintC("Client ");
dbPrintC(dbStr(nClient));
dbPrint(" Faild to Auth In (bad pass)");
}
}
if (loadok == false)
{
mnAddInt(SendPacket, OP_VERIFY_FAILED);
mnAddInt(SendPacket, nClient);
mnSendTCP(0, SendPacket, nClient, false, true);
dbPrintC("Client ");
dbPrintC(dbStr(nClient));
dbPrint(" Failed to Auth In (no acct)");
}
}
Here is the .xml document:
<?xml version="1.0" standalone=no>
<account>
<username>test</username>
<password>1234</password>
</account>
Alright!
You can see the commented out code after 'if (loadok == true)' where i've been trying different approaches.
What seems to be happening is that as soon as the if statment, 'if (loadok == true)' actually triggers, my application crashes and throws an exception!
Fifteen hours and I can't crack this. I'm probably going about everything 100% incorrect. Someone set me straight? Lol.
Edit: I finally solved the problem on my own, turns out I was doing a few things wrong, sorry that i've double posted a few times, this bug was really bothering me >.<