XmlAttribute::Value Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the value of the node.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

property String^ Value {
	virtual String^ get() override;
	virtual void set(String^ value) override;

Property Value

Type: System::String^

The value returned depends on the NodeType of the node. For XmlAttribute nodes, this property is the value of attribute.

Exception Condition

The node is read-only and a set operation is called.

The following example displays information on each of the nodes in the attribute collection.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
   XmlDocument^ doc = gcnew XmlDocument;
   doc->LoadXml( "<book xmlns:bk='urn:samples' bk:genre='novel'><title>Pride And Prejudice</title></book>" );

   //Create an attribute collection.
   XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes;
   Console::WriteLine( "Display information on each of the attributes... \r\n" );
   System::Collections::IEnumerator^ myEnum = attrColl->GetEnumerator();
   while ( myEnum->MoveNext() )
      XmlAttribute^ attr = safe_cast<XmlAttribute^>(myEnum->Current);
      Console::Write( "{0}:{1} = {2}", attr->Prefix, attr->LocalName, attr->Value );
      Console::WriteLine( "\t namespaceURI={0}", attr->NamespaceURI );

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top