XmlAttribute.Name Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient le nom qualifié du nœud.
public:
virtual property System::String ^ Name { System::String ^ get(); };
public override string Name { get; }
member this.Name : string
Public Overrides ReadOnly Property Name As String
Valeur de propriété
Nom qualifié du nœud d'attribut.
Exemples
L’exemple suivant affiche des informations sur chacun des nœuds de la collection d’attributs.
#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 );
}
}
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);
}
}
}
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