Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

XmlAttribute::LocalName Property

Gets the local name of the node.

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

public:
virtual property String^ LocalName {
	String^ get () override;
}

Property Value

Type: System::String
The name of the attribute node with the prefix removed. In the following example <book bk:genre= 'novel'>, the LocalName of the attribute is genre.

If the node does not have a prefix, LocalName is the same as Name.

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 );
   }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0
Show:
© 2015 Microsoft