Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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