次の方法で共有


XmlTextReader.Item プロパティ

属性の値を取得します。

[C#] C# では、このプロパティは XmlTextReader クラスのインデクサになります。

オーバーロードの一覧

指定した名前の属性の値を取得します。

[Visual Basic] Overloads Overrides Public Default ReadOnly Property Item(String) As String

[C#] public override string this[string] {get;}

[C++] public: __property String* get_Item(String*);

[JScript] XmlTextReader.Item (String)

指定したインデックスの属性の値を取得します。

[Visual Basic] Overloads Overrides Public Default ReadOnly Property Item(Integer) As String

[C#] public override string this[int] {get;}

[C++] public: __property String* get_Item(int);

[JScript] XmlTextReader.Item (int)

指定したローカル名および名前空間 URI に関連付けられた属性の値を取得します。

[Visual Basic] Overloads Overrides Public Default ReadOnly Property Item(String, String) As String

[C#] public override string this[string, string] {get;}

[C++] public: __property String* get_Item(String*, String*);

[JScript] XmlTextReader.Item (String, String)

使用例

[Visual Basic, C#, C++] 現在のノードのすべての属性を表示する例を次に示します。

[Visual Basic, C#, C++] メモ   ここでは、Item プロパティ (XmlTextReader インデクサ) のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。

 
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++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

参照

XmlTextReader クラス | XmlTextReader メンバ | System.Xml 名前空間