Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

XmlForm.NamespaceManager property

Gets a reference to a XmlNamespaceManager object that can be used to resolve, add, or remove namespaces used in the form.

Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)
public abstract XmlNamespaceManager NamespaceManager { get; }

Property value

Type: System.Xml.XmlNamespaceManager
An XmlNamespaceManager that can be used resolve, add, or remove namespaces used in the form.

The XmlNamespaceManager object is initialized at load time with all the namespaces defined in the xDocumentClass element of the form template form definition file (.xsf).

A developer can use the instance of the XmlNamespaceManager class to resolve, add, or remove namespaces from the form template. For browser-enabled forms, the class is persisted on the server. All namespaces added using the XmlNamespaceManager class are persisted in the session state of the form template so that they are available across all requests for the form.

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

This type or member can be accessed from code running in forms opened in Microsoft InfoPath Filler or in a Web browser.

In the following code example, the NamespaceManager property is used to get an instance of the System.Xml.XmlNamespaceManager class that is then used to resolve namespaces when using the System.Xml.XPath.XPathNavigator.SelectSingleNode method to select a field.

public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
   // Create XPathNavigator positioned at the root of the main data 
   // source.
   XPathNavigator myNav = this.MainDataSource.CreateNavigator()

   // Select employee field and set value to username.
   myNav.SelectSingleNode("//my:employee",this.NamespaceManager).
      SetValue(System.Environment.UserName);
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.