次の方法で共有


XmlTextReader.MoveToAttribute メソッド (Int32)

指定したインデックスを持つ属性に移動します。

Overrides Overloads Public Sub MoveToAttribute( _
   ByVal i As Integer _)
[C#]
public override void MoveToAttribute(inti);
[C++]
public: void MoveToAttribute(inti);
[JScript]
public override function MoveToAttribute(
   i : int);

パラメータ

  • i
    属性のインデックス。

例外

例外の種類 条件
ArgumentOutOfRangeException i パラメータが 0 未満か、 AttributeCount 以上です。

使用例

[Visual Basic, C#, C++] 現在のノードのすべての属性を表示する例を次に示します。

 
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 'DisplayAttributes

[C#] 
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.
  }
}

[C++] 
public:
void DisplayAttributes(XmlReader* reader)
{
  if (reader->HasAttributes)
  {
    Console::WriteLine(S"Attributes of <{0}>", reader->Name);
    for (int i = 0; i < reader->AttributeCount; i++)
    {
      reader->MoveToAttribute(i);
      Console::Write(S" {0}={1}", reader->Name, reader->Value);
    }
    reader->MoveToElement(); //Moves the reader back to the element node.
  }
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard

参照

XmlTextReader クラス | XmlTextReader メンバ | System.Xml 名前空間 | XmlTextReader.MoveToAttribute オーバーロードの一覧