Re: [xml] xmlParseMemory returns 0



Hi Martin,

It's your C compiler, which kindly implements the standard feature
"trigraphs", which is a method of expressing several characters
by triples starting with "??". 

To avoid trigraph substitution, you can split the string literal:

const char * input = 
      "<?xml version=\"1.0\"?>  <BADTAG>Is this considered invalid XML ?" 
"?</BADTAG>";

Or escape the second '?', but I recommend against, as this
is undefined behaviour under C++ and string splitting works
for both languages.

Regards,
Peter Jacobi

From:                   "Martin Glass" <martinglass attbi com>
To:                     <xml gnome org>
Subject:                [xml] xmlParseMemory returns 0
Date sent:              Tue, 3 Sep 2002 22:07:15 -0600

Hi all,
  I have compiled libxml2 (2.4.24) under Windows, and am successfully
parsing all my stuff, with one exception -- xmlParseMemory always returns
null when the content of a tag ends in "??".  I checked it with xmllint, and
it didn't complain...
  Is there something I've forgotten to do?  This just seems a little strange
to me.

Thanks,
Martin

The following code sums it up:

const char * input = \
      "<?xml version=\"1.0\"?>
  <BADTAG>Is this considered invalid XML ??</BADTAG>";

void main ()
{
  xmlDocPtr doc;
  int size = strlen(input);
  printf("size: %d\n", size);

  doc = xmlParseMemory(input, size);
  printf("doc: %p\n", doc);
};


_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]