Hi!
I am using Expat to parse XML files. I have implemented start/end/data handlers for my parser. My parser is able to parse XML files, but it does not return after it has completed parsing. When I tracked down the problem, the cause was XML_Parse that does not return in its final call. I have checked that "done" changes to true on its final call. The final call to XML_Parse does not throw any exceptions, it is simply stuck. Below is the method which calls XML_Parse(). Any help would be appreciated. Thank you.
I am using Expat to parse XML files. I have implemented start/end/data handlers for my parser. My parser is able to parse XML files, but it does not return after it has completed parsing. When I tracked down the problem, the cause was XML_Parse that does not return in its final call. I have checked that "done" changes to true on its final call. The final call to XML_Parse does not throw any exceptions, it is simply stuck. Below is the method which calls XML_Parse(). Any help would be appreciated. Thank you.
Code:
void
XMLParser::ParseXML(BFile* file)
{
char msg[1024];
XML_Parser parser = XML_ParserCreate(NULL);
XML_SetUserData(parser, this);
XML_SetElementHandler(parser, StartElementHandler, EndElementHandler);
XML_SetCharacterDataHandler(parser, CharDataHandler);
bool done = false;
do {
ssize_t len = file->Read(fBuffer, BUFSIZ);
if (len < BUFSIZ) {
done = true;
}
if (!XML_Parse(parser, fBuffer, len, done)) {
sprintf(msg, "%s at line %d\n",
XML_ErrorString(XML_GetErrorCode(parser)),
XML_GetCurrentLineNumber(parser));
printf(msg);
}
} while (!done);
XML_ParserFree(parser);
}