• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

Testing return results in MSXML4.0

I'm using MSXML4.0 and have a question about testing the return value of some functions.  I'm using XPath as my selection langauges so I frequently attempt to retrieve nodes using:

    Dim Node As IXMLDOMNode

    node = XMLDoc.selectSingleNode("/foo/bar")

What I would like to do is test the value of the node to ensure it is valid before calling methods on it.  The documentation for selectSingleNode says the return value is Nothing if no node is found to match the XPath expression.  I tried the following:

    If Node = Nothing Then

but I got the following error:

    Compiler Error
    Invalid Use of Object

How can I test the validity of my object in this case?
0
derekl
Asked:
derekl
1 Solution
 
GoodJunCommented:
may be try
If Node then
0
 
EDDYKTCommented:
Dim Node As IXMLDOMNode

set node = XMLDoc.selectSingleNode("/foo/bar")

if not node is nothing then
  ' do something
endif
0
 
dereklAuthor Commented:
Thanks.

I'm just curious why If Node doesn't work.  When I try that I get a "Object doesn't support method" error.  I'm thinking maybe a node doesn't support a conversion to boolean?
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now