Solved

Testing return results in MSXML4.0

Posted on 2002-06-26
3
152 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
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Use Multiple Forms 4 38
Access 2016 VB code 9 86
Using "ScreenUpdating" 6 45
Excel VBA, find a string in a column, update a cell 7 51
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now