Original Post
I am trying to parse a file that looks like this:
<Conversation id="1">
<Line id="1">
<Content>FDAFASFAF</Content>
</Line>
</Conversation>
<Conversation id="2">
<Line id="1">
<Content>BLAHBLAHAH</Content>
</Line>
<Line id="2">
<Content>BLAHAHAHA</Content>
</Line>
</Conversation>
So I use this code:
std::vector<CDialogueEntity*> temp;
//Load xml file with param given in method
TiXmlDocument doc(dialogueFile);
loadXMLOkay = doc.LoadFile();
//Check to see if XML file loaded correctly
if (!loadXMLOkay)
{
gameManager->log << "Error: Dialogue file loading FAILED: " << dialogueFile << "\n";
}
else
{
gameManager->log << "Dialogue file loading succeeded: " << dialogueFile << "\n";
}
//Parse all conversations
node = doc.FirstChild("Dialogue");
for(TiXmlElement *diaAction = node->FirstChildElement("Conversation"); diaAction; diaAction = diaAction->NextSiblingElement())
{
CDialogueEntity* ent = new CDialogueEntity();
//Acquire conversation ID
attribute = diaAction->FirstAttribute();
convoID = attribute->Value();
//Show debug info
gameManager->log << "\nDialogue Conversation ID: " << convoID << "\n";
ent->setConvoID(atoi(convoID));
for(TiXmlElement *diaAction2 = node->FirstChildElement("Line"); diaAction2; diaAction2 = diaAction2->NextSiblingElement())
{
//Acquire line ID
attribute = diaAction2->FirstAttribute();
lineID = attribute->Value();
ent->setLineID(atoi(lineID));
node = node->FirstChild("Content");
text = node->FirstChild()->ToText();
content = text->Value();
contentString = content;
ent->setLine(contentString);
//Debug Info
gameManager->log << "\nLine ID:" << lineID << "Content: " << content << "\n";
}
temp.push_back(ent);
//Debug Info
gameManager->log << "End of Conversation\n";
}
But, that only prints the conversation stuff to the log...it is like it's skipping the second for loop. Any idea as to why? [Edited by - brcolow on February 21, 2005 5:24:37 PM]