IsNode issues - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

IsNode issues

Last post 04-14-2010 06:38 AM by Jimmy. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-09-2010 07:53 AM

    IsNode issues

    Hi all, 

    I use vb to get data through my form. I have some optional fileds in my form and I have this problem with the following code:

     MsgBox(myXPathNavigator.SelectSingleNode("/my:Status/my:Questions/my:Questions1", _

     When the optional filed 'Questions1' is inserted to the form I get the value 'true' by the IsNode function. If the field it is not inserted I have an exception,

    stating that the reference is not correct (and it is indeed true). Is there a way to verify about a node, whether it is present or not in my form?

    Thanks in advance,


    Filed under: , ,
  • 04-14-2010 12:57 AM In reply to

    A workaround would be



    isnode= myXPathNavigator.SelectSingleNode("/my:Status/my:Questions/my:Questions1", _


    catch (Exception ex)


    isnode =false


    if (isnode)


    //action if present




    //action if not present


    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 04-14-2010 03:36 AM In reply to

     Thanks for the answer.

    I found another way as follows, just verifying or not the node:

    Dim q As XPathNavigator
    Dim path as String

    = "/my:Status/my:Questions/my:Questions1"
    = myXPathNavigator.SelectSingleNode(path, Me.NamespaceManager)

    If Not q Is Nothing Then
    End If


  • 04-14-2010 06:38 AM In reply to

     The IsNode property is a bit of a pointless property because it is always true.  I think it's more conventional to check whether the result of SelectSingleNode() is null (or Nothing in vb).  You don't really need a try...catch block.  Try this:

     MsgBox((myXPathNavigator.SelectSingleNode("/my:Status/my:Questions/my:Questions1", _
                           Me.NamespaceManager) Is Nothing).ToString)

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.