XMLNode.Attributes Property (2007 System)

Gets a XMLNodes collection that represents the attributes for the XMLNode control.

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

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property Attributes As XMLNodes
'Usage
Dim instance As XMLNode 
Dim value As XMLNodes 

value = instance.Attributes
[BrowsableAttribute(false)]
public XMLNodes Attributes { get; }
[BrowsableAttribute(false)]
public:
property XMLNodes^ Attributes {
    XMLNodes^ get ();
}
public function get Attributes () : XMLNodes

Property Value

Type: XMLNodes
A XMLNodes collection that represents the attributes for the XMLNode control.

Remarks

All XMLNode controls in the XMLNodes collection returned by using the Attributes property have a XMLNodeNodeType property value of wdXMLNodeAttribute.

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 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 Security

See Also

Reference

XMLNode Class

XMLNode Members

Microsoft.Office.Tools.Word Namespace