XmlReader.Item[] Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
When overridden in a derived class, gets the value of the attribute.
Item[Int32] |
When overridden in a derived class, gets the value of the attribute with the specified index. |
Item[String] |
When overridden in a derived class, gets the value of the attribute with the specified Name. |
Item[String, String] |
When overridden in a derived class, gets the value of the attribute with the specified LocalName and NamespaceURI. |
- Source:
- XmlReader.cs
- Source:
- XmlReader.cs
- Source:
- XmlReader.cs
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:
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
Parameters
- i
- Int32
The index of the attribute.
Property Value
The value of the specified attribute.
Exceptions
An XmlReader method was called before a previous asynchronous operation finished. In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."
Examples
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
Remarks
This property does not move the reader.
See also
Applies to
.NET 9 и други версии
Продукт | Версии |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
- Source:
- XmlReader.cs
- Source:
- XmlReader.cs
- Source:
- XmlReader.cs
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:
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
Parameters
- name
- String
The qualified name of the attribute.
Property Value
The value of the specified attribute. If the attribute is not found, null
is returned.
Exceptions
An XmlReader method was called before a previous asynchronous operation finished. In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."
Examples
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)
Remarks
This property does not move the reader.
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"]
See also
Applies to
.NET 9 и други версии
Продукт | Версии |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
- Source:
- XmlReader.cs
- Source:
- XmlReader.cs
- Source:
- XmlReader.cs
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:
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
Parameters
- name
- String
The local name of the attribute.
- namespaceURI
- String
The namespace URI of the attribute.
Property Value
The value of the specified attribute. If the attribute is not found, null
is returned.
Exceptions
An XmlReader method was called before a previous asynchronous operation finished. In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."
Remarks
This property does not move the reader.
See also
Applies to
.NET 9 и други версии
Продукт | Версии |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
Обратна връзка за .NET
.NET е проект с отворен код. Изберете връзка, за да предоставите обратна връзка: