XmlAttribute.Name-Eigenschaft
Ruft den gekennzeichneten Namen des Knotens ab.
Namespace: System.Xml
Assembly: System.Xml (in system.xml.dll)
Syntax
'Declaration
Public Overrides ReadOnly Property Name As String
'Usage
Dim instance As XmlAttribute
Dim value As String
value = instance.Name
public override string Name { get; }
public:
virtual property String^ Name {
String^ get () override;
}
/** @property */
public String get_Name ()
public override function get Name () : String
Eigenschaftenwert
Der gekennzeichnete Name des Attributknotens.
Beispiel
Im folgenden Beispiel werden Informationen über die einzelnen Knoten in der Attributauflistung angezeigt.
Imports System
Imports System.IO
Imports System.Xml
public class Sample
public shared sub Main()
Dim doc as XmlDocument = new XmlDocument()
doc.LoadXml("<book xmlns:bk='urn:samples' bk:genre='novel'>" & _
"<title>Pride And Prejudice</title>" & _
"</book>")
'Create an attribute collection.
Dim attrColl as XmlAttributeCollection = doc.DocumentElement.Attributes
Console.WriteLine("Display information on each of the attributes... ")
Dim attr as XmlAttribute
for each attr in attrColl
Console.Write("{0} = {1}", attr.Name, attr.Value)
Console.WriteLine(" namespaceURI=" + attr.NamespaceURI)
next
end sub
end class
using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main(){
XmlDocument doc = new 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");
foreach (XmlAttribute attr in attrColl){
Console.Write("{0} = {1}", attr.Name, attr.Value);
Console.WriteLine("\t namespaceURI=" + attr.NamespaceURI);
}
}
}
#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}", attr->Name, attr->Value );
Console::WriteLine( "\t namespaceURI={0}", attr->NamespaceURI );
}
}
import System.*;
import System.IO.*;
import System.Xml.*;
public class Sample
{
public static void main(String[] args)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book xmlns:bk='urn:samples' bk:genre='novel'>"
+ "<title>Pride And Prejudice</title>"
+ "</book>");
//Create an attribute collection.
XmlAttributeCollection attrColl =
doc.get_DocumentElement().get_Attributes();
Console.WriteLine("Display information on each of the"
+ " attributes... \r\n");
for (int iCtr = 0; iCtr < attrColl.get_Count(); iCtr++) {
XmlAttribute attr = attrColl.get_ItemOf(iCtr);
Console.Write("{0} = {1}", attr.get_Name(), attr.get_Value());
Console.WriteLine("\t namespaceURI=" + attr.get_NamespaceURI());
}
} //main
} //Sample
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
XmlAttribute-Klasse
XmlAttribute-Member
System.Xml-Namespace
XmlAttribute.LocalName-Eigenschaft