[xsde-users] Re: Using minimal configuration, problem parsing using multiroot example

Boris Kolpackov boris at codesynthesis.com
Thu Dec 2 07:17:55 EST 2010

Hi Terry,

O'Laughlin, Terry <Terry.O'Laughlin at ipc.com> writes:

> I am getting a parser error after completion of parsing (doc_p.parse),
> error 2, xml error, ‘invalid token’.

Here is the relevant parts of your code:

  char buf[4096] ;


  size_t s = fread (buf, 1, sizeof (buf), f);


  doc_p.parse ( buf, sizeof(buf), true );

You allocate a buffer 4096 bytes long, then read some data into it,
which has size 's'. Then you try to parse 4096 bytes of XML. Unless
the XML file you are trying to parse is exactly 4096 bytes long,
the buffer will contain garbage after the 's' bytes. If I change
the last line in the above code to read as follows, the error goes

doc_p.parse ( buf, s, true );


More information about the xsde-users mailing list