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



Elvis Stansvik wrote:
2008/11/14 Andrew Hartley <andrew hartley bcs org uk>:
Ok, sorry.  I am using VS2005 and the code is in a Regular DLL using shared
MFC.  The version of LibXml2 that I am statically linking to is: 2-2.6.32+

I am loading the Xml from a resource within the DLL in the InitInstance():

------------------------------------------------------------------------------
           CWinApp::InitInstance();

       char szResName[]        = "#7001";
       char szResType[]        = "TAXONOMYXML";
       HMODULE hMod = AfxGetResourceHandle();

       //      Load the Xml resource:
       HRSRC hRes = FindResource(hMod, szResName, szResType);

       if (hRes)
       {
               HGLOBAL hBytes  = LoadResource(hMod, hRes);
               LPVOID  lpData  = LockResource(hBytes);
               LPBYTE  lpbData = (LPBYTE)lpData;

               m_pXbrlTaxonomy = new CXbrlTaxonomy(reinterpret_cast<const
char*>(lpbData));
       }
       return TRUE;
(...)
Andrew Hartley wrote:
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.


Never have used resources in this way, but my personal guess would be that the resource is not correctly NULL terminated (no clue if it's supposed to be).

Have you checked the length with:
  DWORD SizeofResource(HMODULE hModule, HRSRC hResInfo);
  Returns the size, in bytes, of the specified resource.

br,
Martin



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