XmlAttributeCollection.ItemOf[] Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene l'attributo con il nome o l'indice specificati.
Overload
| Nome | Descrizione |
|---|---|
| ItemOf[Int32] |
Ottiene l'attributo con l'indice specificato. |
| ItemOf[String] |
Ottiene l'attributo con il nome specificato. |
| ItemOf[String, String] |
Ottiene l'attributo con il nome locale e l'URI (Uniform Resource Identifier) specificati. |
ItemOf[Int32]
- Origine:
- XmlAttributeCollection.cs
- Origine:
- XmlAttributeCollection.cs
- Origine:
- XmlAttributeCollection.cs
- Origine:
- XmlAttributeCollection.cs
- Origine:
- XmlAttributeCollection.cs
Ottiene l'attributo con l'indice specificato.
public:
property System::Xml::XmlAttribute ^ default[int] { System::Xml::XmlAttribute ^ get(int i); };
public:
virtual property System::Xml::XmlAttribute ^ default[int] { System::Xml::XmlAttribute ^ get(int i); };
public System.Xml.XmlAttribute this[int i] { get; }
public virtual System.Xml.XmlAttribute this[int i] { get; }
member this.ItemOf(int) : System.Xml.XmlAttribute
Default Public ReadOnly Property ItemOf(i As Integer) As XmlAttribute
Default Public Overridable ReadOnly Property ItemOf(i As Integer) As XmlAttribute
Parametri
- i
- Int32
Indice dell'attributo.
Valore della proprietà
Attributo in corrispondenza dell'indice specificato.
Eccezioni
L'indice passato non è compreso nell'intervallo.
Esempio
Nell'esempio seguente vengono visualizzati tutti gli attributi dell'insieme.
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>");
//Create an attribute collection.
XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;
Console.WriteLine("Display all the attributes in the collection...\r\n");
for (int i=0; i < attrColl.Count; i++)
{
Console.Write("{0} = ", attrColl[i].Name);
Console.Write("{0}", attrColl[i].Value);
Console.WriteLine();
}
}
}
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>")
'Create an attribute collection.
Dim attrColl as XmlAttributeCollection = doc.DocumentElement.Attributes
Console.WriteLine("Display all the attributes in the collection...")
Dim i as integer
for i=0 to attrColl.Count-1
Console.Write("{0} = ", attrColl.ItemOf(i).Name)
Console.Write("{0}", attrColl.ItemOf(i).Value)
Console.WriteLine()
next
end sub
end class
Commenti
Questa proprietà è un'estensione Microsoft per il DOM (Document Object Model). Equivale a chiamare XmlNamedNodeMap.Item.
Vedi anche
Si applica a
ItemOf[String]
- Origine:
- XmlAttributeCollection.cs
- Origine:
- XmlAttributeCollection.cs
- Origine:
- XmlAttributeCollection.cs
- Origine:
- XmlAttributeCollection.cs
- Origine:
- XmlAttributeCollection.cs
Ottiene l'attributo con il nome specificato.
public:
property System::Xml::XmlAttribute ^ default[System::String ^] { System::Xml::XmlAttribute ^ get(System::String ^ name); };
public:
virtual property System::Xml::XmlAttribute ^ default[System::String ^] { System::Xml::XmlAttribute ^ get(System::String ^ name); };
public System.Xml.XmlAttribute this[string name] { get; }
public System.Xml.XmlAttribute? this[string name] { get; }
public virtual System.Xml.XmlAttribute this[string name] { get; }
member this.ItemOf(string) : System.Xml.XmlAttribute
Default Public ReadOnly Property ItemOf(name As String) As XmlAttribute
Default Public Overridable ReadOnly Property ItemOf(name As String) As XmlAttribute
Parametri
- name
- String
Nome completo dell'attributo.
Valore della proprietà
Attributo con il nome specificato. Se l'attributo non esiste, questa proprietà restituisce null.
Esempio
Nell'esempio seguente viene rimosso un attributo dal documento.
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>");
//Create an attribute collection and remove an attribute
//from the collection.
XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;
attrColl.Remove(attrColl["genre"]);
Console.WriteLine("Display the modified XML...\r\n");
Console.WriteLine(doc.OuterXml);
}
}
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>")
'Create an attribute collection and remove an attribute
'from the collection.
Dim attrColl as XmlAttributeCollection = doc.DocumentElement.Attributes
attrColl.Remove(attrColl.ItemOf("genre"))
Console.WriteLine("Display the modified XML...")
Console.WriteLine(doc.OuterXml)
end sub
end class
Commenti
Questa proprietà è un'estensione Microsoft per il DOM (Document Object Model). Equivale a chiamare GetNamedItem.
Si applica a
ItemOf[String, String]
- Origine:
- XmlAttributeCollection.cs
- Origine:
- XmlAttributeCollection.cs
- Origine:
- XmlAttributeCollection.cs
- Origine:
- XmlAttributeCollection.cs
- Origine:
- XmlAttributeCollection.cs
Ottiene l'attributo con il nome locale e l'URI (Uniform Resource Identifier) specificati.
public:
property System::Xml::XmlAttribute ^ default[System::String ^, System::String ^] { System::Xml::XmlAttribute ^ get(System::String ^ localName, System::String ^ namespaceURI); };
public:
virtual property System::Xml::XmlAttribute ^ default[System::String ^, System::String ^] { System::Xml::XmlAttribute ^ get(System::String ^ localName, System::String ^ namespaceURI); };
public System.Xml.XmlAttribute this[string localName, string namespaceURI] { get; }
public System.Xml.XmlAttribute? this[string localName, string? namespaceURI] { get; }
public virtual System.Xml.XmlAttribute this[string localName, string namespaceURI] { get; }
member this.ItemOf(string * string) : System.Xml.XmlAttribute
Default Public ReadOnly Property ItemOf(localName As String, namespaceURI As String) As XmlAttribute
Default Public Overridable ReadOnly Property ItemOf(localName As String, namespaceURI As String) As XmlAttribute
Parametri
- localName
- String
Nome locale dell'attributo.
- namespaceURI
- String
URI dello spazio dei nomi dell'attributo.
Valore della proprietà
Attributo con il nome locale e l'URI dello spazio dei nomi specificati. Se l'attributo non esiste, questa proprietà restituisce null.
Commenti
Questa proprietà è un'estensione Microsoft per il DOM (Document Object Model). Equivale a chiamare GetNamedItem.