[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Problem on MSXML IXMLDOMDocument.load()

  • From: Michael Brennan <Michael_Brennan@a...>
  • To: "'Owen, Noel'" <NOwen@s...>, xml-dev@l...
  • Date: Thu, 24 May 2001 18:12:57 -0700

ixmldomdocument load
By default, the DOM document loads XML asynchronously. That means they way
you've coded it, the XML may not be parsed, yet, when you try to access the
root document element. Also, if a parse error occurs, it will not return an
HResult indicating failure. You should be passing the address of a
VARIANT_BOOL as the second argument to load. That will be set to false if
the parse fails, true if it succeeds.

For example, replace your "load" line with something like the following:

  hr = pobjSchemaIXMLDOMDocumentPtr->put_async(VARIANT_FALSE);
  VARIANT_BOOL fSuccess;
  hr = pobjSchemaIXMLDOMDocumentPtr->load("sample.xml", &fSuccess);
  if ( FAILED(hr))
  {
	// handle COM failure
  }
  else if(fSuccessful != VARIANT_TRUE)
  {
	// handle parse error
  }



> -----Original Message-----
> From: Owen, Noel [mailto:NOwen@s...]
> Sent: Thursday, May 24, 2001 5:30 PM
> To: xml-dev@l...
> Subject: Problem on MSXML IXMLDOMDocument.load()
> 
> 
> Hi guys,
> 
> I'm having trouble using the load() method of 
> IXMLDOMDocument. Somehow the
> load() is working, and as a result, the pIXMLDOMElement 
> returns NULL.  Have
> you tried using load() before, and did it work?
> 
> 
> 
> 
> **************************************************************
> **************
> ************************************************ My source code:
> 
> 	IXMLDOMDocumentPtr	pobjSchemaIXMLDOMDocumentPtr = NULL;
> 
> 	hr = CoCreateInstance(CLSID_DOMDocument, NULL, 
> CLSCTX_INPROC_SERVER,
> IID_IXMLDOMDocument, (void **) &pobjSchemaIXMLDOMDocumentPtr);
> 	if (FAILED(hr))
> 	{
> 		printf("Bad\n");
> 		return(0);
> 	}
> 	else if (NULL == pobjSchemaIXMLDOMDocumentPtr)
> 	{
> 		printf("Bad\n");
> 		return(0);
> 	}
> 	
> 	hr = pobjSchemaIXMLDOMDocumentPtr->load("sample.xml");
> 	if (FAILED(hr))
> 	{
> 		printf("Bad\n");
> 		return(0);
> 	}
> 
> 	IXMLDOMElement *pIXMLDOMElement = NULL;
> 	hr =
> pobjSchemaIXMLDOMDocumentPtr->get_documentElement(&pIXMLDOMElement);
> 	if (FAILED(hr))
> 	{
> 		printf("Bad\n");
> 		return(0);
> 	}
> 	else if (pIXMLDOMElement)
> 	{
> 		printf("Good\n");
> 
> 	}
> 	else
> 	{
> 		printf("Bad\n");
> 		return(0);
> 	}
> 
> 
> 
> ------------------------------------------------------------------
> The xml-dev list is sponsored by XML.org, an initiative of OASIS
> <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To unsubscribe from this elist send a message with the single word
> "unsubscribe" in the body to: xml-dev-request@l...
> 

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.