473,378 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Expat's XML_Parse() method does not return

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.

Expand|Select|Wrap|Line Numbers
  1. void
  2. XMLParser::ParseXML(BFile* file)
  3. {
  4.     char msg[1024];
  5.  
  6.     XML_Parser parser = XML_ParserCreate(NULL);
  7.     XML_SetUserData(parser, this);
  8.     XML_SetElementHandler(parser, StartElementHandler, EndElementHandler);
  9.     XML_SetCharacterDataHandler(parser, CharDataHandler);
  10.  
  11.     bool done = false;
  12.     do {
  13.         ssize_t len = file->Read(fBuffer, BUFSIZ);
  14.         if (len < BUFSIZ) {
  15.             done = true;
  16.         }
  17.         if (!XML_Parse(parser, fBuffer, len, done)) {
  18.             sprintf(msg, "%s at line %d\n",
  19.                     XML_ErrorString(XML_GetErrorCode(parser)),
  20.                     XML_GetCurrentLineNumber(parser));
  21.             printf(msg);
  22.         }
  23.     } while (!done);
  24.  
  25.     XML_ParserFree(parser);
  26. }
Jul 26 '08 #1
0 1766

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jakob Møbjerg Nielsen | last post by:
Expat keeps telling me that there is "junk after document element". I've tried different encoding, and I'm quite sure that the buffer is nul-terminated. I really have no idea to what the problem...
4
by: Jeff Lambert | last post by:
I saw something similar on the sourceforge bugs list but it was from 2001 so I assume it's fixed by now. O/S: WinXP SP2 and WinCE. Expat lib linked in VC++ 6 SP6. I have the following XML...
4
by: Sridhar | last post by:
HI All, Currently writing a small program and here is my xml file and program. --------------------------------------------------------------------------------- <?xml version="1.0"...
4
by: Maarten Verhage | last post by:
Hi All, I've made a modified version of the Expat elements.c example. What I want the program to do is to recognize a hardcoded element-name/tag-name and then execute some code which has access...
5
by: A.Martini | last post by:
Hello, I have to parse an xml file which has entities like &8220; ” and apostrophes ('). I have created a parser and I parse the xml but the xml_parse function convert entities and apostrophes to...
2
by: sharan | last post by:
like for a example xml program <?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>...
5
by: panky.tiwari | last post by:
Hi, I have an XML File while I am parsing through Expat and in Chunks. The code snippet I am using XML_Parser p = XML_ParserCreate(NULL); if(!p) { print_k("Unable to create Parser\n");...
1
by: vadlapatlahari | last post by:
Hi, I get the following error with Expat while configuring my application server. Can anyone suggest a solution? When i do an ldd, i get the following : $ldd Expat.so Expat.so needs:...
1
by: porchemasi | last post by:
Im trying to parse the following <channel> <newsItem> <newsTitle>U.S. Tops Guatemala 2-0 in Cup Qualifier (AP)</newsTitle> <reporters> <reporter>RONALD BLUM</reporter> </reporters> ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.