This documentation is archived and is not being maintained.
XmlElement.Attributes Property
.NET Framework 1.1
Gets an XmlAttributeCollection containing the list of attributes for this node.
[Visual Basic] Overrides Public ReadOnly Property Attributes As _ XmlAttributeCollection [C#] public override XmlAttributeCollection Attributes {get;} [C++] public: __property XmlAttributeCollection* get_Attributes(); [JScript] public override function get Attributes() : XmlAttributeCollection;
Property Value
XmlAttributeCollection containing the list of attributes for this node.
Example
[Visual Basic, C#, C++] The following example uses changes the value of the first attribute.
[Visual Basic] Imports System Imports System.IO Imports System.Xml public class Sample public shared sub Main() Dim doc as XmlDocument = new XmlDocument() doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" & _ "<title>Pride And Prejudice</title>" & _ "</book>") Dim root as XmlElement = doc.DocumentElement ' Change the value of the first attribute. root.Attributes.Item(0).Value="fiction" Console.WriteLine("Display the modified XML...") Console.WriteLine(doc.InnerXml) end sub end class [C#] using System; using System.IO; using System.Xml; public class Sample { public static void Main() { XmlDocument doc = new XmlDocument(); doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" + "<title>Pride And Prejudice</title>" + "</book>"); XmlElement root = doc.DocumentElement; // Change the value of the first attribute. root.Attributes[0].Value="fiction"; Console.WriteLine("Display the modified XML..."); Console.WriteLine(doc.InnerXml); } } [C++] #using <mscorlib.dll> #using <System.Xml.dll> using namespace System; using namespace System::IO; using namespace System::Xml; int main() { XmlDocument* doc = new XmlDocument(); doc->LoadXml(S"<book genre='novel' ISBN='1-861001-57-5'><title>Pride And Prejudice</title></book>"); XmlElement* root = doc->DocumentElement; // Change the value of the first attribute. root->Attributes->ItemOf[0]->Value=S"fiction"; Console::WriteLine(S"Display the modified XML..."); Console::WriteLine(doc->InnerXml); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
See Also
XmlElement Class | XmlElement Members | System.Xml Namespace
Show: