Solved

Testing return results in MSXML4.0

Posted on 2002-06-26
3
159 Views
Last Modified: 2010-05-02
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
Comment
Question by:derekl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Expert Comment

by:GoodJun
ID: 7111699
may be try
If Node then
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 100 total points
ID: 7111708
Dim Node As IXMLDOMNode

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

if not node is nothing then
  ' do something
endif
0
 

Author Comment

by:derekl
ID: 7111929
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question