次の方法で共有


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)

Syntax

'Declaration
Public MustOverride ReadOnly Property NamespaceManager As XmlNamespaceManager
    Get
'Usage
Dim instance As XmlForm
Dim value As XmlNamespaceManager

value = instance.NamespaceManager
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.

Remarks

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.

Examples

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);
}
Public Sub FormEvents_Loading(ByVal sender As Object, ByVal e As LoadingEventArgs)
   ' Create XPathNavigator positioned at the root of the main data 
   ' source.
   Dim myNav As XPathNavigator = Me.MainDataSource.CreateNavigator()

   ' Select employee field and set value to username.
   myNav.SelectSingleNode("//my:employee", Me.NamespaceManager). _
      SetValue(System.Environment.UserName)
End Sub

See Also

Reference

XmlForm Class

XmlForm Members

Microsoft.Office.InfoPath Namespace