Check if Object is assigned to xml-node

If the node id in an XML-Node doesn't exist the following code showed that oID is "nothing"

    'id
    Set oID = oUserdetails.selectSingleNode("id")
    id = oID.nodeTypedValue

So I tried only to assign value of oID to id when the node exists

    'id
    Set oID = oUserdetails.selectSingleNode("id")
    If oID <> Null Then
        id = oID.nodeTypedValue
    End If

But VB says that the object doesn't support this property "<> Null"

Thanks for any help

Marc
ExcattalaAsked:
Who is Participating?
 
TimCotteeConnect With a Mentor Commented:
Hi Excattala,

You should test that the object IS Nothing:

If Not(oID Is Nothing) Then
  id = oID.NodeTypedValue

Tim Cottee MCSD, MCDBA, CPIM
http://www.timcottee.tk 

Brainbench MVP for Visual Basic
http://www.brainbench.com

Experts-Exchange Advisory Board Member
0
All Courses

From novice to tech pro — start learning today.