XmlTextReader.MoveToAttribute Metoda

Definicja

Przenosi się do określonego atrybutu.

Przeciążenia

MoveToAttribute(Int32)

Przenosi się do atrybutu z określonym indeksem.

MoveToAttribute(String)

Przenosi się do atrybutu o określonej nazwie.

MoveToAttribute(String, String)

Przenosi się do atrybutu z określoną lokalną nazwą i identyfikatorem URI przestrzeni nazw.

Uwagi

Uwaga

Począwszy od .NET Framework 2.0, zalecamy utworzenie XmlReader wystąpień przy użyciu metody , aby korzystać z XmlReader.Create nowych funkcji.

MoveToAttribute(Int32)

Przenosi się do atrybutu z określonym indeksem.

public:
 override void MoveToAttribute(int i);
public override void MoveToAttribute (int i);
override this.MoveToAttribute : int -> unit
Public Overrides Sub MoveToAttribute (i As Integer)

Parametry

i
Int32

Indeks atrybutu.

Wyjątki

Parametr i jest mniejszy niż 0 lub większy niż lub równy AttributeCount.

Przykłady

Poniższy przykład przedstawia wszystkie atrybuty w bieżącym węźle.

public:
   void DisplayAttributes( XmlReader^ reader )
   {
      if ( reader->HasAttributes )
      {
         Console::WriteLine( "Attributes of <{0}>", 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 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

Uwagi

Uwaga

Począwszy od .NET Framework 2.0, zalecamy utworzenie XmlReader wystąpień przy użyciu metody , aby korzystać z XmlReader.Create nowych funkcji.

Zobacz też

Dotyczy

MoveToAttribute(String)

Przenosi się do atrybutu o określonej nazwie.

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

Parametry

name
String

Kwalifikowana nazwa atrybutu.

Zwraca

Boolean

true jeśli atrybut zostanie znaleziony; w przeciwnym razie , false. Jeśli falsepozycja czytelnika nie zmieni się.

Uwagi

Uwaga

Począwszy od .NET Framework 2.0, zalecamy utworzenie XmlReader wystąpień przy użyciu metody , aby korzystać z XmlReader.Create nowych funkcji.

Po wywołaniu MoveToAttributewłaściwości , NamespaceURINamei Prefix odzwierciedlają właściwości tego atrybutu.

Zobacz też

Dotyczy

MoveToAttribute(String, String)

Przenosi się do atrybutu z określoną lokalną nazwą i identyfikatorem URI przestrzeni nazw.

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

Parametry

localName
String

Lokalna nazwa atrybutu.

namespaceURI
String

Identyfikator URI przestrzeni nazw atrybutu.

Zwraca

Boolean

true jeśli atrybut zostanie znaleziony; w przeciwnym razie , false. Jeśli falsepozycja czytelnika nie zmieni się.

Uwagi

Uwaga

Począwszy od .NET Framework 2.0, zalecamy utworzenie XmlReader wystąpień przy użyciu metody , aby korzystać z XmlReader.Create nowych funkcji.

Po wywołaniu MoveToAttributewłaściwości , NamespaceURINamei Prefix odzwierciedlają właściwości tego atrybutu.

Zobacz też

Dotyczy