[Expat-discuss] Beginner's question

Sidney Richards sidney.richards@xs4all.nl
Wed, 23 Oct 2002 18:33:02 +0200


This is a multi-part message in MIME format.

---------------------- multipart/alternative attachment
Hey all,

Ran into a small problem earlier on. While trying to parse a chunk of =
XML, read into a char* using fread from a textfile, I get a parse error:

Not well-formed (invalid token)

Here's the function call:
 if (XML_Parse(parser, xml_buffer, strlen(xml_buffer),true) =3D=3D =
XML_STATUS_ERROR) {
      fprintf(stderr, "Parse error at line %d:\n%s\n",
              XML_GetCurrentLineNumber(parser),
              XML_ErrorString(XML_GetErrorCode(parser)));
  }

The thing is, it parses the entire document fine, but the problem seems =
to lie in the strlen(xml_buffer) call, because if I use

 if (XML_Parse(parser, xml_buffer, strlen(xml_buffer)-4,true) =3D=3D=20

the error disappears. There doesn't seem to be any junk characters in =
the file (and it gets parsed without a problem if I open the xml file in =
IE).

Anyone know what might be causing this?

Cheers,

Sid

---------------------- multipart/alternative attachment--