Tutorial :Selecting a node from an InfoPath form


I am trying to get an XmlNode within an InfoPath form, and I can't get it to return anything but null.. I'm following the example at http://suguk.org/forums/thread/17780.aspx and running into this issue..

MemoryStream inStream = new MemoryStream(file.OpenBinary());  XmlDocument myDoc = new XmlDocument();  myDoc.PreserveWhitespace = true;  myDoc.Load(inStream);    XmlElement root = myDoc.DocumentElement;  XPathNavigator navigator = form.CreateNavigator();    XmlNamespaceManager manager = new XmlNamespaceManager(navigator.NameTable);  manager.AddNamespace("my", "http://schemas.microsooft.comm/office/infopath/2003/myXSD/2008-09-22T20:08::03");  XmlNode fieldToAlter = root.SelectSingleNode("/my:myFields/my:field2", manager);  

The last line is setting fieldToAlter to null... Any ideas? The XPath that I am using, I got by right clicking on the field in InfoPath and selecting "Copy XPath."


Try this instead: manager.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-09-22T20:08::03");

(changed microsooft.comm to microsoft.com) :)

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »