[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Problem on MSXML IXMLDOMDocument.load()
- From: Michael Brennan <Michael_Brennan@allegis.com>
- To: "'Owen, Noel'" <NOwen@saratogasystems.com>, xml-dev@lists.xml.org
- Date: Thu, 24 May 2001 18:12:57 -0700
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
>