XmlAttributeCollection.ItemOf[] Tulajdonság
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Lekéri a megadott névvel vagy indexel rendelkező attribútumot.
Túlterhelések
| Név | Description |
|---|---|
| ItemOf[Int32] |
Lekéri a megadott indexet tartalmazó attribútumot. |
| ItemOf[String] |
Lekéri a megadott névvel rendelkező attribútumot. |
| ItemOf[String, String] |
Lekéri az attribútumot a megadott helyi névvel és névtér egységes erőforrás-azonosítójával (URI). |
ItemOf[Int32]
- Forrás:
- XmlAttributeCollection.cs
- Forrás:
- XmlAttributeCollection.cs
- Forrás:
- XmlAttributeCollection.cs
- Forrás:
- XmlAttributeCollection.cs
- Forrás:
- XmlAttributeCollection.cs
Lekéri a megadott indexet tartalmazó attribútumot.
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
Paraméterek
- i
- Int32
Az attribútum indexe.
Tulajdonság értéke
A megadott index attribútuma.
Kivételek
Az átadott index tartományon kívül esik.
Példák
Az alábbi példa a gyűjtemény összes attribútumát megjeleníti.
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
Megjegyzések
Ez a tulajdonság a Dokumentumobjektum-modell (DOM) Microsoft bővítménye. Ez egyenértékű a hívással XmlNamedNodeMap.Item.
Lásd még
A következőre érvényes:
ItemOf[String]
- Forrás:
- XmlAttributeCollection.cs
- Forrás:
- XmlAttributeCollection.cs
- Forrás:
- XmlAttributeCollection.cs
- Forrás:
- XmlAttributeCollection.cs
- Forrás:
- XmlAttributeCollection.cs
Lekéri a megadott névvel rendelkező attribútumot.
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
Paraméterek
- name
- String
Az attribútum minősített neve.
Tulajdonság értéke
A megadott névvel rendelkező attribútum. Ha az attribútum nem létezik, ez a tulajdonság ad vissza null.
Példák
Az alábbi példa eltávolít egy attribútumot a dokumentumból.
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
Megjegyzések
Ez a tulajdonság a Dokumentumobjektum-modell (DOM) Microsoft bővítménye. Ez egyenértékű a hívással GetNamedItem.
A következőre érvényes:
ItemOf[String, String]
- Forrás:
- XmlAttributeCollection.cs
- Forrás:
- XmlAttributeCollection.cs
- Forrás:
- XmlAttributeCollection.cs
- Forrás:
- XmlAttributeCollection.cs
- Forrás:
- XmlAttributeCollection.cs
Lekéri az attribútumot a megadott helyi névvel és névtér egységes erőforrás-azonosítójával (URI).
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
Paraméterek
- localName
- String
Az attribútum helyi neve.
- namespaceURI
- String
Az attribútum névterének URI-ja.
Tulajdonság értéke
A megadott helyi névvel és névtér URI-val rendelkező attribútum. Ha az attribútum nem létezik, ez a tulajdonság ad vissza null.
Megjegyzések
Ez a tulajdonság a Dokumentumobjektum-modell (DOM) Microsoft bővítménye. Ez egyenértékű a hívással GetNamedItem.