Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Thu, 18 Oct 2007 02:19:20 -0700,    group: microsoft.public.platformsdk.com_ole        back       


getAttribute returns E_NOINTERFACE   
I'm using the dreaded MSMXL (3.0 to be precise). Somehow, I've managed to
teach myself a boggling amount of COM in the last 24 hours or so, but I've
run into a stumper.

My app calls the get_documentElement method of IXMLDOMDocument, then calls
the getAttribute method of the resulting instance of IXMLDOMElement. This
works just fine. I then call the get_childNodes method to obtain the
children of said element. I then verify these children are themselves
elements by means of get_nodeType, and out of diagnostic paranoia I call
QueryInterface to make sure IID_IXMLDOMElement is supported. You'd think the
child elements would be ready to respond to getAttribute, wouldn't you? It
worked on the parent element, so why wouldn't it work on the child elements?
In fact, getAttribute returns E_NOINTERFACE.

I'd love to be able to post my code, but it's one of those situations in
which it's deeply intertwingled with a big class library and it probably
wouldn't make much sense without the big picture.

I've looked at all the parameters a thousand times, I've made sure I've set
up the right environment (as simple a threading model as possible), I've
Googled various things, and I've only unearthed two clues, neither of which
is a solution.

First, there's this HippoFlickr code which seems to do roughly the same
thing I'm doing.

http://svn.mugshot.org/dumbhippo/branches/cluster/client/windows/HippoUI/Hip
poFlickr.cpp

I don't know whether this code actually works, of course, but at least
someone else has gone down the same road. (Search for get_childNodes and
you'll see what I mean.)

Second, there's this note from Raymond Chen on E_NOINTERFACE.

http://blogs.msdn.com/oldnewthing/archive/2004/12/13/281910.aspx

Basically, he says CoCreateInstance will return E_NOINTERFACE in some
difficult-to-diagnose-but-not-entirely-obscure cases. I'm not calling
CoCreateInstance, and in fact I'm not calling anything I would expect to
call CoCreateInstance. Why would getAttribute call CoCreateInstance for some
elements but not others? Nevertheless, it's an idea.

Any insight appreciated.


                                                 Pete Gontier
                                                 http://www.m-audio.com/
                                                 pete (at) m-audio (dot) com


                                                 Pete Gontier
                                                 http://www.m-audio.com/
                                                 pete (at) m-audio (dot) com
date: Thu, 18 Oct 2007 02:19:20 -0700   author:   Pete Gontier

Re: getAttribute returns E_NOINTERFACE   
OK, I can now simplify the explanation a bit due to an experiment.

I have two instances of IXMLDOMElement, a parent and one of its children. I
got the child via the get_childNodes method of the parent. The parent works
fine. I have successfully verified that the child...

    --  is a NODE_ELEMENT according to get_nodeType
    --  responds affirmatively when I pass IID_IXMLDOMElement to
        QueryInterface
    --  responds as expected when I call get_nodeName

However, the child's getAttribute returns E_NOINTERFACE, suggesting that it
is not what I have so carefully verified it to be.



                                                 Pete Gontier
                                                 http://www.m-audio.com/
                                                 pete (at) m-audio (dot) com
date: Thu, 18 Oct 2007 10:38:58 -0700   author:   Pete Gontier

Re: getAttribute returns E_NOINTERFACE   
OK, this was a rookie mistake.

It's not enough to get a child node pointer and cast it to an element
pointer; one must explicitly obtain an element interface pointer from the
child node. The fact that get_nodeType produces NODE_ELEMENT only makes it
very likely that QueryInterface will successfully produce an instance of
IID_IXMLDOMElement.

Confusing the issue was the fact that I was passing IID_IXMLDOMElement to
QueryInterface purely as a diagnostic to verify that I already had an
instance of IID_IXMLDOMElement. This was a misunderstanding on my part of
QueryInterface. In fact, I did not have an instance of IID_IXMLDOMElement
UNTIL I passed IID_IXMLDOMElement to QueryInterface, after which I promptly
threw away the newly created instance because I thought it was of no value
other than diagnostic.

Did I say this was a rookie mistake already? Good.


On 10/18/07 10:38 AM, in article
C33CE842.2B7E8%kokorozashi@discussions.microsoft.com, "Pete Gontier"
 wrote:

> OK, I can now simplify the explanation a bit due to an experiment.
> 
> I have two instances of IXMLDOMElement, a parent and one of its children. I
> got the child via the get_childNodes method of the parent. The parent works
> fine. I have successfully verified that the child...
> 
>     --  is a NODE_ELEMENT according to get_nodeType
>     --  responds affirmatively when I pass IID_IXMLDOMElement to
>         QueryInterface
>     --  responds as expected when I call get_nodeName
> 
> However, the child's getAttribute returns E_NOINTERFACE, suggesting that it
> is not what I have so carefully verified it to be.
date: Thu, 18 Oct 2007 11:58:40 -0700   author:   Pete Gontier

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us