hello everyone,
I'm unable to select a single node within my xml document :-/
http://msdn.microsoft.com/en-us/library/aa701078.aspx
protected void XmlFormView1_Initialize(object sender,
InitializeEventArgs e)
{
// Create an XPathNavigator positioned at the root of the form's main data source.
XPathNavigator xNavMain = XmlFormView1.XmlForm.MainDataSource.CreateNavigator();
// Create an XmlNamespaceManager and add the "my" namespace alias from the form's main data source.
XmlNamespaceManager xNameSpace = new XmlNamespaceManager(new NameTable());
xNameSpace.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-04-20T16:26:21");
// Create an XPathNavigator positioned on the form's field2.
XPathNavigator fTextBox1 = xNavMain.SelectSingleNode("my:myFields/my:field2", xNameSpace);
// Set the form's field2 to the value in TextBox1.
fTextBox1.SetValue(TextBox1.Text);
}
First of all... my uri for the "my" namespace is different as Infopath seems to create a new uri for each xml document.
I therefore tried to use xNavMain.LookupNamespace("my")... but that doesn't return much (null).
xNavMain.SelectSingleNode("/myFields/my:forename", xNameSpace); always returns null.The XML as returned by XPathNavigator xNavMain = XmlFormView1.XmlForm.MainDataSource.CreateNavigator();
<?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:MyEmptyTemplateFour:-myXSD-2009-07-05T16-25-14" solutionVersion="1.0.0.13" productVersion="12.0.0.0" PIVersion="1.0.0.0" href="http://portal.litwareinc.com/MyPublishingSite/MyFormsLibrary/MyTestForms/MyEmptyTemplateFour.xsn"?>
<?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?>
<my:myFields xml:lang="en-US"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-07-05T16:25:14"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
<my:CbAllowSubmit>true</my:CbAllowSubmit>
<my:forename></my:forename>
<my:lastname></my:lastname>
</my:myFields>
It looks okay, right?