Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.
Moves to the specified attribute.
MoveToAttribute(Int32) |
Moves to the attribute with the specified index. |
MoveToAttribute(String) |
Moves to the attribute with the specified name. |
MoveToAttribute(String, String) |
Moves to the attribute with the specified local name and namespace URI. |
Note
We recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.
Moves to the attribute with the specified index.
public:
override void MoveToAttribute(int i);
public override void MoveToAttribute(int i);
override this.MoveToAttribute : int -> unit
Public Overrides Sub MoveToAttribute (i As Integer)
The index of the attribute.
The i
parameter is less than 0 or greater than or equal to AttributeCount.
The following example displays all attributes on the current node.
public void DisplayAttributes(XmlReader reader)
{
if (reader.HasAttributes)
{
Console.WriteLine("Attributes of <" + reader.Name + ">");
for (int i = 0; i < reader.AttributeCount; i++)
{
reader.MoveToAttribute(i);
Console.Write(" {0}={1}", reader.Name, reader.Value);
}
reader.MoveToElement(); //Moves the reader back to the element node.
}
}
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
reader.MoveToAttribute(i)
Console.Write(" {0}={1}", reader.Name, reader.Value)
Next i
reader.MoveToElement() 'Moves the reader back to the element node.
End If
End Sub
Note
We recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.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 | 2.0, 2.1 |
Moves to the attribute with the specified name.
public:
override bool MoveToAttribute(System::String ^ name);
public override bool MoveToAttribute(string name);
override this.MoveToAttribute : string -> bool
Public Overrides Function MoveToAttribute (name As String) As Boolean
The qualified name of the attribute.
true
if the attribute is found; otherwise, false
. If false
, the reader's position does not change.
Note
We recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.
After calling MoveToAttribute
, the Name, NamespaceURI, and Prefix properties reflects the properties of that attribute.
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.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 | 2.0, 2.1 |
Moves to the attribute with the specified local name and namespace URI.
public:
override bool MoveToAttribute(System::String ^ localName, System::String ^ namespaceURI);
public override bool MoveToAttribute(string localName, string? namespaceURI);
public override bool MoveToAttribute(string localName, string namespaceURI);
override this.MoveToAttribute : string * string -> bool
Public Overrides Function MoveToAttribute (localName As String, namespaceURI As String) As Boolean
The local name of the attribute.
The namespace URI of the attribute.
true
if the attribute is found; otherwise, false
. If false
, the reader's position does not change.
Note
We recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.
After calling MoveToAttribute
, the Name, NamespaceURI, and Prefix properties reflects the properties of that attribute.
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.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 | 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Please sign in to use this experience.
Sign in