Freigeben über


XMLNode.NamespaceURI-Eigenschaft

Ruft den URI (Uniform Resource Identifier) des Schemanamespace für das XMLNode-Steuerelement ab.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

Syntax

'Declaration
ReadOnly Property NamespaceURI As String
string NamespaceURI { get; }

Eigenschaftswert

Typ: System.String
Der URI des Schemanamespace für das XMLNode-Steuerelement.

Hinweise

Wenn Sie XML-Schemas erstellen, um sie mit Microsoft Office Word zu verwenden, wird dringend empfohlen, im Schema die TargetNamespace-Einstellung anzugeben.

Beispiele

Im folgenden Codebeispiel wird mithilfe der Attributes-Eigenschaft einem XMLNode-Steuerelement ein Attribut hinzugefügt. Die NamespaceURI-Eigenschaft wird zur Angabe des Schemanamespace verwendet. Anschließend werden alle Attribute im XMLNode durchlaufen, und die Attributnamen und die jeweiligen Werte werden angezeigt. Der Name des XMLNode wird aus der BaseName-Eigenschaft abgerufen. In diesem Beispiel wird davon ausgegangen, dass das aktuelle Dokument einen XMLNode mit dem Namen CustomerNode enthält, für den ein NewCustomer-Attribut im Schema deklariert ist.

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
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 +
            "'.");
    }
}

.NET Framework-Sicherheit

Siehe auch

Referenz

XMLNode Schnittstelle

Microsoft.Office.Tools.Word-Namespace