Aracılığıyla paylaş


XMLNode.NamespaceURI Property

Definition

Gets the Uniform Resource Identifier (URI) of the schema namespace for the XMLNode control.

public:
 property System::String ^ NamespaceURI { System::String ^ get(); };
public string NamespaceURI { get; }
member this.NamespaceURI : string
Public ReadOnly Property NamespaceURI As String

Property Value

The URI of the schema namespace for the XMLNode control.

Examples

The following code example uses the Attributes property to add an attribute to an XMLNode control. The NamespaceURI property is used to specify the schema namespace. The example then iterates through every attribute in the XMLNode and displays the attribute name and its value. The name of the XMLNode is obtained from the BaseName property. This example assumes that the current document contains an XMLNode named CustomerNode that has a NewCustomer attribute declared in the schema.

private void DisplayAttributes()
{
    Word.XMLNode newAttribute = 
        this.CustomerNode.Attributes.Add("NewCustomer",
        this.CustomerNode.NamespaceURI, ref missing);
    newAttribute.NodeValue = "yes";

    foreach (Word.XMLNode attribute1 in this.CustomerNode.Attributes)
    {
        MessageBox.Show("'" + this.CustomerNode.BaseName +
            "' has the attribute '" + attribute1.BaseName +
            "' with the value '" + attribute1.NodeValue +
            "'.");
    }
}
Private Sub DisplayAttributes()
    Dim newAttribute As Word.XMLNode = _
        Me.CustomerNode.Attributes.Add("NewCustomer", _
        Me.CustomerNode.NamespaceURI)
    newAttribute.NodeValue = "yes"

    Dim attribute1 As Word.XMLNode
    For Each attribute1 In Me.CustomerNode.Attributes
        MsgBox("'" & Me.CustomerNode.BaseName & _
            "' has the attribute '" & attribute1.BaseName & _
            "' with the value '" & attribute1.NodeValue & "'.")
    Next attribute1
End Sub

Remarks

If you are authoring XML schemas for use with Microsoft Office Word, it is highly recommended that you specify the TargetNamespace setting in the schema.

Applies to