tags:

views:

79

answers:

1

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."

+1  A: 

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) :)

Chloraphil
My VM doubles letters when it's lagging. Same thing happened with .comm....Thanks!