XmlReader.MoveToNextAttribute XmlReader.MoveToNextAttribute XmlReader.MoveToNextAttribute XmlReader.MoveToNextAttribute Method

定义

当在派生类中被重写时,移动到下一个属性。When overridden in a derived class, moves to the next attribute.

public:
 abstract bool MoveToNextAttribute();
public abstract bool MoveToNextAttribute ();
abstract member MoveToNextAttribute : unit -> bool
Public MustOverride Function MoveToNextAttribute () As Boolean

返回

如果存在下一个属性,则为 true;如果没有其他属性,则为 falsetrue if there is a next attribute; false if there are no more attributes.

异常

在上一次异步操作完成之前调用了 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.

if (reader.HasAttributes) {
  Console.WriteLine("Attributes of <" + reader.Name + ">");
  while (reader.MoveToNextAttribute()) {
    Console.WriteLine(" {0}={1}", reader.Name, reader.Value);
  }
  // Move the reader back to the element node.
  reader.MoveToElement();
}
If reader.HasAttributes Then
  Console.WriteLine("Attributes of <" + reader.Name + ">")
  While reader.MoveToNextAttribute()
    Console.WriteLine(" {0}={1}", reader.Name, reader.Value)
  End While
  ' Move the reader back to the element node.
  reader.MoveToElement()
End If

注解

如果当前节点是元素节点,此方法等同于MoveToFirstAttributeIf the current node is an element node, this method is equivalent to MoveToFirstAttribute. 如果MoveToNextAttribute返回true,读取器移动到下一步属性; 否则为读取器位置不会更改。If MoveToNextAttribute returns true, the reader moves to the next attribute; otherwise, the position of the reader does not change.

适用于