指定したインデックスの属性の値を取得します。
[C#] C# では、このプロパティは XmlTextReader クラスのインデクサになります。
Overrides Overloads Public Default ReadOnly Property Item( _
ByVal i As Integer _) As String
[C#]
public override string this[inti] {get;}
[C++]
public: __property String* get_Item(inti);
[JScript]
returnValue = XmlTextReaderObject.Item(i);またはreturnValue = XmlTextReaderObject(i);
[JScript] JScript では、この型で定義されている既定のインデックス プロパティを使用することができます。しかし、独自のインデックス プロパティを明示的に定義することはできません。ただし、このクラスの expando 属性を指定すると、既定のインデックス プロパティが提供されます。提供されるインデックス プロパティの型は Object 型であり、インデックス型は String になります。
引数 [JScript]
- i
属性のインデックス。
パラメータ [Visual Basic, C#, C++]
- i
属性のインデックス。
プロパティ値
属性の値。
例外
例外の種類 | 条件 |
---|---|
ArgumentOutOfRangeException | i パラメータが 0 未満か、 AttributeCount 以上です。 |
解説
このプロパティは、リーダーを移動しません。
使用例
[Visual Basic, C#, C++] 現在のノードのすべての属性を表示する例を次に示します。
Public Sub DisplayAttributes(reader As XmlReader)
If reader.HasAttributes Then
Console.WriteLine("Attributes of <" & reader.Name & ">")
Dim i As Integer
For i = 0 To reader.AttributeCount - 1
Console.WriteLine(" {0}", reader(i))
Next i
End If
End Sub 'DisplayAttributes
[C#]
public void DisplayAttributes(XmlReader reader)
{
if (reader.HasAttributes)
{
Console.WriteLine("Attributes of <" + reader.Name + ">");
for (int i = 0; i < reader.AttributeCount; i++)
{
Console.WriteLine(" {0}", reader[i]);
}
}
}
[C++]
public:
void DisplayAttributes(XmlReader* reader)
{
if (reader->HasAttributes)
{
Console::WriteLine(S"Attributes of <{0}>", reader->Name);
for (int i = 0; i < reader->AttributeCount; i++)
{
Console::WriteLine(S" {0}", reader->Item[i]);
}
}
}
[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 ファミリ, Common Language Infrastructure (CLI) Standard
参照
XmlTextReader クラス | XmlTextReader メンバ | System.Xml 名前空間 | XmlTextReader.Item オーバーロードの一覧 | GetAttribute