OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

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

RE: Problem on MSXML IXMLDOMDocument.load()



Hi Michael,

Thanks for replying my msg.

This MSXML is totally new to me.  I was wondering when I integrate the MSXML
stuff into my application, do I just do the #import as follow:

#import msxml4.dll
using namespace MSXML2;

Or I should do the include and link the msxml.lib:

#include "msxml2.h"


Currently, I'm using the #import way, and the load() is not working.  In
fact, the load() takes only 1 parameter.  That is, it's a little bit
different from the original load() which takes 2 parameters.  And then I can
see in the msxml.tlh that there's another operation called raw_load() which
takes 2 parameters.  And that's the reason why I'm passing in just the XML
file path as the 1 parameter into the load() as follow:

hr = pobjSchemaIXMLDOMDocumentPtr->load("sample.xml");

And the whole thing is not working.

Could you provide me more info concerning how to integrate the MSXML into my
program.

Thanks.


Noel Owen
nowen@saratogasystems.com
(O) 408-558-9614   (Fax) 408-558-9690


-----Original Message-----
From: Michael Brennan [mailto:Michael_Brennan@allegis.com]
Sent: Thursday, May 24, 2001 6:13 PM
To: 'Owen, Noel'; xml-dev@lists.xml.org
Subject: RE: Problem on MSXML 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@saratogasystems.com]
> Sent: Thursday, May 24, 2001 5:30 PM
> To: xml-dev@lists.xml.org
> 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@lists.xml.org
>