Microsoft Knowledge Base Email Alertz

When you use the Microsoft XML Document Object Model (MSXML) IStream interface to load an XML file from the stream, you receive an HRESULT from its Load() method of either 0xc00ce558 or 0xc00ce500.

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 255799 - Last Review: May 11, 2006 - Revision: 2.0

PRB: Cannot Load XML Documents from Stream

This article was previously published under Q255799

SYMPTOMS

When you use the Microsoft XML Document Object Model (MSXML) IStream interface to load an XML file from the stream, you receive an HRESULT from its Load() method of either 0xc00ce558 or 0xc00ce500.

This problem occurs when you use use both the Load() method of IPersistStream or IPersistStreamInit, as well as when you use the Load() method of IXMLDomDocument and pass a VT_UNKNOWN pointer to your IStream.

CAUSE

This can happen if the seek pointer is not set to the beginning of the stream before you call the Load() method. Use the IPersistStream::Seek() method to reset the seek pointer.

RESOLUTION

The following code loads an XML document from a URL, saves it to a stream, and restores it back into a separate DOMDocument object. If you don't reset the seek pointer, you will receive the error messaged mentioned in the "Symptoms" section of this article.
#import "msxml3.dll"
using namespace MSXML2;

void dump_com_error(_com_error &e)
{
	printf("Error\n");
	printf("\a\tCode = %08lx\n", e.Error());
	printf("\a\tCode meaning = %s", e.ErrorMessage());
	_bstr_t bstrSource(e.Source());
	_bstr_t bstrDescription(e.Description());
	printf("\a\tSource = %s\n", (LPCSTR) bstrSource);
	printf("\a\tDescription = %s\n", (LPCSTR) bstrDescription);
}


int main(int argc, char* argv[])
{
	CoInitialize(NULL);
	
	
	try{
		IXMLDOMDocumentPtr pXMLDoc;
		HRESULT hr = pXMLDoc.CreateInstance(__uuidof(DOMDocument));
		
		pXMLDoc->async = false; // default - true,
		
		
		hr = pXMLDoc->load("stock.xml");
		
		if(hr!=VARIANT_TRUE)
		{
			IXMLDOMParseErrorPtr  pError;
			
			pError = pXMLDoc->parseError;
			_bstr_t parseError =_bstr_t("At line ")+ _bstr_t(pError->Getline()) + _bstr_t("\n")+ _bstr_t(pError->Getreason());
			MessageBox(NULL,parseError, "Parse Error",MB_OK);
			return 0;
		}
		
		CComPtr<IStream> pStream;
		hr = CreateStreamOnHGlobal(NULL, true, &pStream);
		hr = pXMLDoc->save(pStream.p);
		
		LARGE_INTEGER pos;
		pos.QuadPart = 0;
		
		//the key is to reset the seek pointer
		pStream->Seek((LARGE_INTEGER)pos, STREAM_SEEK_SET, NULL);

		IXMLDOMDocumentPtr pXMLDocNew;
		hr = pXMLDocNew.CreateInstance(__uuidof(DOMDocument));
		pXMLDocNew->async = false;
		hr = pXMLDocNew->load(pStream.p);
		if(hr!=VARIANT_TRUE)
		{
			IXMLDOMParseErrorPtr  pError;
			
			pError = pXMLDocNew->parseError;
			_bstr_t parseError =_bstr_t("At line ")+ _bstr_t(pError->Getline()) + _bstr_t("\n")+ _bstr_t(pError->Getreason());
			MessageBox(NULL,parseError, "Parse Error",MB_OK);
			return 0;
		}

		MessageBox(NULL,(LPTSTR)pXMLDocNew->xml, "XML content",MB_OK);		
		
	}
	catch(_com_error &e)
	{
		dump_com_error(e);
	}
      CoUninitialize();

	return 0;
}

				
If a newer version of MSXML has been installed in side-by-side mode, you must explicitly use the Globally Unique Identifiers (GUIDs) or ProgIDs for that version to run the sample code. For example, MSXML version 4.0 can only be installed in side-by-side mode. For additional information about the code changes that are required to run the sample code with the MSXML 4.0 parser, click the following article number to view the article in the Microsoft Knowledge Base:
305019  (http://kbalertz.com/Feedback.aspx?kbNumber=305019/EN-US/ ) INFO: MSXML 4.0 Specific GUIDs and ProgIds
To run the sample code with MSXML 4.0 parser, you need to make following code changes:
  1. Use #import "msxml4.dll" instead of #import "msxml3.dll".
  2. Use DOMDocument40 in CreateInstance call, for example HRESULT hr = pXMLDoc.CreateInstance(__uuidof(DOMDocument40));

STATUS

This behavior is by design.

REFERENCES

For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:
http://msdn.microsoft.com/ie/ (http://msdn.microsoft.com/ie/)

http://support.microsoft.com/iep (http://support.microsoft.com/iep)

APPLIES TO
  • Microsoft XML Parser 2.0
  • Microsoft XML Parser 2.5
  • Microsoft XML Parser 2.6
  • Microsoft XML Parser 3.0
  • Microsoft Visual C++ 6.0 Service Pack 5
Keywords: 
kbprb KB255799
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate