[Expat-discuss] problem parsing two files in application

Karl Waclawek karl at waclawek.net
Thu May 29 10:01:19 EDT 2003


Do not to treat the input as string. This gives
problems if there a re null bytes, like in a UTF-16 encoding.
Just follow the examples in the docs and demo programs that
come with Expat.

Karl

----- Original Message ----- 
From: "Gururajan, Subhashini (Cognizant)" <GSubhash at chn.cognizant.com>
To: "Greg Martin" <Greg.Martin at TELUS.COM>; <expat-discuss at libexpat.org>
Sent: Thursday, May 29, 2003 3:21 AM
Subject: RE: [Expat-discuss] problem parsing two files in application


Hi,
I get the 'not well-formed (invalid token) " error while parsing.
I do not see any problem with my XML file. Please help me out.


here is the piece of code that i am trying out. attched is the XML file that i am parsing

while(!feof(fp)){
    int done;
    int len;
    fgets(Buff, sizeof(Buff), fp);
    len = strlen(Buff);
    if (ferror(fp)) {
      fprintf(stderr, "Read error\n");
      exit(-1);
    }
    if (! parser.parse(Buff, len)) {
      fprintf(stderr, "Parse error at line :\n#%s#\n",Buff);
        printf("Error: %s",parser.getErrorString(parser.getErrorCode()));
      exit(-1);
    }
  }


int XMLExpatParser::parse(const char* buffer, int len)
{
        m_pXmlBuffer = new char[255];
        strncpy(m_pXmlBuffer,buffer,strlen(buffer));
        m_nDepth     = 0;
        if(len == 0)
        return XML_Parse(m_pXMLExpatParser, m_pXmlBuffer, strlen(m_pXmlBuffer),
len);
        else
        return XML_Parse(m_pXMLExpatParser, m_pXmlBuffer, len, 0);
}

Regards,
-Subhashini

-----Original Message-----
From: Greg Martin [mailto:Greg.Martin at TELUS.COM]
Sent: Tuesday, May 27, 2003 9:28 PM
To: expat-discuss at libexpat.org
Subject: FW: [Expat-discuss] problem parsing two files in application



Thanks for your help Karl. Using your suggestion stopped the error and pointed to the real problem.
For reasons beyond my ken I had shadowed the done variable so it was changing value with each loop -
mea culpa not expat.
Greg.

-----Original Message-----
From: Karl Waclawek [mailto:karl at waclawek.net]
Sent: Tuesday, May 27, 2003 9:08 AM
To: Greg Martin; expat-discuss at libexpat.org
Subject: Re: [Expat-discuss] problem parsing two files in application


I couldn't see anything wrong with your code.

Does this happen always with the second file you parse, not matter which file?
Or is it always the same file? Have you checked the file for extra characters at the end?

You could also try this:
...
  if(XML_Parse(p, buf, len, len == 0) == XML_STATUS_ERROR)
...

Karl

----- Original Message ----- 
From: "Greg Martin" <Greg.Martin at TELUS.COM>
To: <expat-discuss at libexpat.org>
Sent: Tuesday, May 27, 2003 10:34 AM
Subject: RE: [Expat-discuss] problem parsing two files in application


Thanks for the quick reply. I'm using expat-1.95.6 built for Compaq Tru64.






_______________________________________________
Expat-discuss mailing list
Expat-discuss at libexpat.org
http://mail.libexpat.org/mailman/listinfo/expat-discuss



--------------------------------------------------------------------------------


> _______________________________________________
> Expat-discuss mailing list
> Expat-discuss at libexpat.org
> http://mail.libexpat.org/mailman/listinfo/expat-discuss
>




More information about the Expat-discuss mailing list