XmlReader.Item[String, String] XmlReader.Item[String, String] XmlReader.Item[String, String] XmlReader.Item[String, String] Property

定义

重载

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

当在派生类中被重写时,获取具有指定索引的属性的值。When overridden in a derived class, gets the value of the attribute with the specified index.

Item[String] Item[String] Item[String] Item[String]

当在派生类中被重写时,获取具有指定 Name 的属性的值。When overridden in a derived class, gets the value of the attribute with the specified Name.

Item[String, String] Item[String, String] Item[String, String] Item[String, String]

当在派生类中被重写时,获取具有指定 LocalNameNamespaceURI 的属性的值。When overridden in a derived class, gets the value of the attribute with the specified LocalName and NamespaceURI.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

当在派生类中被重写时,获取具有指定索引的属性的值。When overridden in a derived class, gets the value of the attribute with the specified index.

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

参数

i
Int32 Int32 Int32 Int32

属性的索引。The index of the attribute.

属性值

指定的属性的值。The value of the specified attribute.

异常

在上一次异步操作完成之前调用了 XmlReader 方法。An XmlReader method was called before a previous asynchronous operation finished. 在此情况下,会引发 InvalidOperationException 并显示消息“异步操作已在进行中。”In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

示例

下面的示例显示当前节点上的所有属性。The following example displays all attributes on the current node.

// 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

注解

此属性不会移动读取器。This property does not move the reader.

另请参阅

Item[String] Item[String] Item[String] Item[String]

当在派生类中被重写时,获取具有指定 Name 的属性的值。When overridden in a derived class, gets the value of the attribute with the specified Name.

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

参数

name
String String String String

属性的限定名称。The qualified name of the attribute.

属性值

指定的属性的值。The value of the specified attribute. 如果未找到该属性,则返回 nullIf the attribute is not found, null is returned.

异常

在上一次异步操作完成之前调用了 XmlReader 方法。An XmlReader method was called before a previous asynchronous operation finished. 在此情况下,会引发 InvalidOperationException 并显示消息“异步操作已在进行中。”In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

示例

下面的示例获取的 ISBN 属性的值。The following example gets the value of the ISBN attribute.

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)

注解

此属性不会移动读取器。This property does not move the reader.

如果读取器定位在DocumentType节点,此方法可用于获取 PUBLIC 和 SYSTEM 文本,例如, reader["PUBLIC"]If the reader is positioned on a DocumentType node, this method can be used to get the PUBLIC and SYSTEM literals, for example, reader["PUBLIC"]

另请参阅

Item[String, String] Item[String, String] Item[String, String] Item[String, String]

当在派生类中被重写时,获取具有指定 LocalNameNamespaceURI 的属性的值。When overridden in a derived class, gets the value of the attribute with the specified LocalName and NamespaceURI.

public:
 virtual 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; }
member this.Item(string * string) : string
Default Public Overridable ReadOnly Property Item(name As String, namespaceURI As String) As String

参数

name
String String String String

属性的本地名称。The local name of the attribute.

namespaceURI
String String String String

属性的命名空间 URI。The namespace URI of the attribute.

属性值

指定的属性的值。The value of the specified attribute. 如果未找到该属性,则返回 nullIf the attribute is not found, null is returned.

异常

在上一次异步操作完成之前调用了 XmlReader 方法。An XmlReader method was called before a previous asynchronous operation finished. 在此情况下,会引发 InvalidOperationException 并显示消息“异步操作已在进行中。”In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

注解

此属性不会移动读取器。This property does not move the reader.

另请参阅

适用于