Re: [xml] xmlReadMemory : error "Extra content at the end of the document"

2008/11/14 Andrew Hartley <andrew hartley bcs org uk>:

Having streamed the std::string content (the Xml) to file in Debug mode and
Release mode, I have found that the Xml in Debug mode is ok (as I knew) BUT
in Release mode the Xml string has the following HEX characters appended at
the end:

0x50 0x41 0x44 0xD0 0x03 0x34

!!!  Unless I find a reason for this I will just have to check for it and
strip these extra PADing chars off.

Yes do what you have to do. In any case this is beyond the control of
the libxml2 library, which expects input to be valid XML, nothing

Hope you'll figure it out.


Andrew Hartley wrote:

I have written a DLL with a large (size = 1318109 chars) XML stored as a
resource.  I read the XML into a std::string and load it with a call to

xmlDocPtr pXmlDoc = xmlReadMemory(sXml, sXml.length(), "xml", NULL, 0);

This works fine in Debug mode.  But when I switch to Release mode I get
NULL returned and the error text is "Extra content at the end of the

I have tried parsing the std::string content into a char*, and setting the
argv[3] to "UTF-8":

             int nLen = (int)sXml.size();
      char* pszContent        = new char[nLen +2];

      strcpy_s(pszContent, nLen +2, sXml.c_str());
      pszContent[nLen]                = '\n';
      pszContent[nLen +1]     = '\0';

      xmlDocPtr pXmlDoc = xmlReadMemory(pszContent, nLen, "xml", "UTF-8", 0);

      delete[] pszContent;
      pszContent = NULL;

But I still get the same error!

I have not resorted to attempting to debug through LibXml2 yet, and would
appreciate any advice.

View this message in context:
Sent from the Gnome - Lib - Xml - General mailing list archive at

xml mailing list, project page
xml gnome org

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