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

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 document".

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 attemting 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 Nabble.com.

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