derekl
asked on
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?
Dim Node As IXMLDOMNode
node = XMLDoc.selectSingleNode("/
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
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?
If Node then