SelectSingleNode not working? - InfoPath Dev
in

InfoPath Dev

SelectSingleNode not working?

Last post 06-03-2010 08:21 AM by Hilary Stoupa. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-03-2010 08:14 AM

    SelectSingleNode not working?

    I'm trying to select the value from a textbox but it keeps returning NULL, I can't for the life of me figure out why.  Here's some info:

     

     

    My code:

    XmlNamespaceManager ns = this.NamespaceManager;
    XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();
    string surname = xnDoc.SelectSingleNode("/my:myFields/my:Policyholder_Surname", ns).Value.ToString();

    I've also tried //my:myFields/my:Policyholder_Surname and //my:Policyholder_Surname

    Any help would be most appreciated!

  • 06-03-2010 08:21 AM In reply to

    Re: SelectSingleNode not working?

    To get the XPath for your SelectSingleNode, right click the node and select "Copy XPath". Then paste that in your quotes (though what you have in your post does look correct). Perhaps before getting the value, create another XPathNavigator variable for the node itself, so you can see if that returns null?

    XPathNavigator surnameNode = xnDoc.SelectSingleNode("/my:myFields/my:Policyholder_Surname", ns);

    Make sure that this node is included in your form by default -- that would be under Tools / Default Values. If the node isn't included by default, it won't be there to select.... 

    Hilary Stoupa

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.