Share via


XMLNode.BaseName 屬性

取得沒有任何前置字串的 XMLNode 控制項名稱。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)

語法

'宣告
ReadOnly Property BaseName As String
    Get
string BaseName { get; }

屬性值

型別:System.String
沒有任何前置字串的 XMLNode 控制項名稱。

範例

下列程式碼範例使用 Attributes 屬性 (Property) 將屬性 (Attribute) 加入至 XMLNode 控制項。 NamespaceURI 屬性會用來指定結構描述命名空間。 然後範例會逐一查看 XMLNode 中的每個屬性,並且顯示屬性名稱和值。 XMLNode 的名稱可從 BaseName 屬性中取得。 這個範例假設目前的文件有包含名為 CustomerNode 的 XMLNode,前者擁有在結構描述中宣告的 NewCustomer 屬性。

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 安全性

請參閱

參考

XMLNode 介面

Microsoft.Office.Tools.Word 命名空間