XmlReader.HasAttributes プロパティ

定義

現在のノードに属性があるかどうかを示す値を取得します。

public:
 virtual property bool HasAttributes { bool get(); };
public virtual bool HasAttributes { get; }
member this.HasAttributes : bool
Public Overridable ReadOnly Property HasAttributes As Boolean

プロパティ値

現在のノードが属性を持っている場合は true。それ以外の場合は false

例外

先行の非同期操作が完了する前に、XmlReader メソッドが呼び出されました。 この場合、「非同期操作が既に実行されています」というメッセージと共に InvalidOperationException がスローされます。

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

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

適用対象