XmlReader.Item[] プロパティ

定義

派生クラスでオーバーライドされると、属性の値を取得します。

オーバーロード

名前 説明
Item[Int32]

派生クラスでオーバーライドされると、指定したインデックスを持つ属性の値を取得します。

Item[String]

派生クラスでオーバーライドされると、指定した Nameを持つ属性の値を取得します。

Item[String, String]

派生クラスでオーバーライドされると、指定した LocalNameNamespaceURIを持つ属性の値を取得します。

Item[Int32]

ソース:
XmlReader.cs
ソース:
XmlReader.cs
ソース:
XmlReader.cs
ソース:
XmlReader.cs
ソース:
XmlReader.cs

派生クラスでオーバーライドされると、指定したインデックスを持つ属性の値を取得します。

public:
 virtual property System::String ^ default[int] { System::String ^ get(int i); };
public:
 abstract property System::String ^ default[int] { System::String ^ get(int i); };
public virtual string this[int i] { get; }
public abstract string this[int i] { get; }
member this.Item(int) : string
Default Public Overridable ReadOnly Property Item(i As Integer) As String
Default Public MustOverride ReadOnly Property Item(i As Integer) As String

パラメーター

i
Int32

属性のインデックス。

プロパティ値

指定した属性の値。

例外

前の非同期操作が完了する前に、 XmlReader メソッドが呼び出されました。 この場合、"非同期操作は既に進行中です" というメッセージで InvalidOperationException がスローされます。

次の例では、現在のノードのすべての属性を表示します。

// Display all attributes.
if (reader.HasAttributes) {
  Console.WriteLine("Attributes of <" + reader.Name + ">");
  for (int i = 0; i < reader.AttributeCount; i++) {
    Console.WriteLine("  {0}", reader[i]);
  }
  // Move the reader back to the element node.
  reader.MoveToElement();
}
' Display all attributes.
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
  ' Move the reader back to the element node.
  reader.MoveToElement()
End If

注釈

このプロパティはリーダーを移動しません。

こちらもご覧ください

適用対象

Item[String]

ソース:
XmlReader.cs
ソース:
XmlReader.cs
ソース:
XmlReader.cs
ソース:
XmlReader.cs
ソース:
XmlReader.cs

派生クラスでオーバーライドされると、指定した Nameを持つ属性の値を取得します。

public:
 virtual property System::String ^ default[System::String ^] { System::String ^ get(System::String ^ name); };
public:
 abstract property System::String ^ default[System::String ^] { System::String ^ get(System::String ^ name); };
public virtual string this[string name] { get; }
public virtual string? this[string name] { get; }
public abstract string this[string name] { get; }
member this.Item(string) : string
Default Public Overridable ReadOnly Property Item(name As String) As String
Default Public MustOverride ReadOnly Property Item(name As String) As String

パラメーター

name
String

属性の修飾名。

プロパティ値

指定した属性の値。 属性が見つからない場合は、 null が返されます。

例外

前の非同期操作が完了する前に、 XmlReader メソッドが呼び出されました。 この場合、"非同期操作は既に進行中です" というメッセージで InvalidOperationException がスローされます。

次の例では、ISBN 属性の値を取得します。

reader.ReadToDescendant("book");
string isbn =reader["ISBN"];
Console.WriteLine("The ISBN value: " + isbn);
reader.ReadToDescendant("book")
Dim isbn As String = reader("ISBN")
Console.WriteLine("The ISBN value: " + isbn)

注釈

このプロパティはリーダーを移動しません。

リーダーが DocumentType ノードに配置されている場合、このメソッドを使用して PUBLIC リテラルと SYSTEM リテラルを取得できます。たとえば、 reader["PUBLIC"]

こちらもご覧ください

適用対象

Item[String, String]

ソース:
XmlReader.cs
ソース:
XmlReader.cs
ソース:
XmlReader.cs
ソース:
XmlReader.cs
ソース:
XmlReader.cs

派生クラスでオーバーライドされると、指定した LocalNameNamespaceURIを持つ属性の値を取得します。

public:
 virtual property System::String ^ default[System::String ^, System::String ^] { System::String ^ get(System::String ^ name, System::String ^ namespaceURI); };
public:
 abstract property System::String ^ default[System::String ^, System::String ^] { System::String ^ get(System::String ^ name, System::String ^ namespaceURI); };
public virtual string this[string name, string namespaceURI] { get; }
public virtual string? this[string name, string? namespaceURI] { get; }
public abstract string this[string name, string namespaceURI] { get; }
member this.Item(string * string) : string
Default Public Overridable ReadOnly Property Item(name As String, namespaceURI As String) As String
Default Public MustOverride ReadOnly Property Item(name As String, namespaceURI As String) As String

パラメーター

name
String

属性のローカル名。

namespaceURI
String

属性の名前空間 URI。

プロパティ値

指定した属性の値。 属性が見つからない場合は、 null が返されます。

例外

前の非同期操作が完了する前に、 XmlReader メソッドが呼び出されました。 この場合、"非同期操作は既に進行中です" というメッセージで InvalidOperationException がスローされます。

注釈

このプロパティはリーダーを移動しません。

こちらもご覧ください

適用対象