指定したインデックスの属性を取得します。
[C#] C# では、このプロパティは XmlAttributeCollection クラスのインデクサになります。
Overloads Public Overridable Default ReadOnly Property ItemOf( _
ByVal i As Integer _) As XmlAttribute
[C#]
public virtual XmlAttribute this[inti] {get;}
[C++]
public: __property virtual XmlAttribute* get_ItemOf(inti);
[JScript]
returnValue = XmlAttributeCollectionObject.ItemOf(i);またはreturnValue = XmlAttributeCollectionObject(i);
[JScript] JScript では、この型で定義されている既定のインデックス プロパティを使用することができます。しかし、独自のインデックス プロパティを明示的に定義することはできません。ただし、このクラスの expando 属性を指定すると、既定のインデックス プロパティが提供されます。提供されるインデックス プロパティの型は Object 型であり、インデックス型は String になります。
引数 [JScript]
- i
属性のインデックス。
パラメータ [Visual Basic, C#, C++]
- i
属性のインデックス。
プロパティ値
指定したインデックス位置にある XmlAttribute 。
解説
このプロパティは、ドキュメント オブジェクト モデル (DOM: Document Object Model) に対する Microsoft 拡張機能です。これは XmlNamedNodeMap.Item の呼び出しと等価です。
使用例
[Visual Basic, C#, C++] コレクションのすべての属性を表示する例を次に示します。
Imports System
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
[C#]
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();
}
}
}
[C++]
#using <mscorlib.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
XmlDocument* doc = new XmlDocument();
doc->LoadXml(S"<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(S"Display all the attributes in the collection...\r\n");
for (int i=0; i < attrColl->Count; i++)
{
Console::Write(S"{0} = ",attrColl->ItemOf[i]->Name);
Console::Write(S"{0}",attrColl->ItemOf[i]->Value);
Console::WriteLine();
}
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
XmlAttributeCollection クラス | XmlAttributeCollection メンバ | System.Xml 名前空間 | XmlAttributeCollection.Item オーバーロードの一覧 | Item