XmlReader.MoveToElement 메서드

정의

파생 클래스에서 재정의되면 현재 Attribute 노드를 포함하는 요소로 이동합니다.

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

반환

Boolean

판독기가 특성에 있으면(특성이 있는 요소로 판독기가 이동하면) true이고, 판독기가 특성에 없으면(판독기의 위치가 바뀌지 않으면) false입니다.

예외

이전 비동기 작업이 완료되기 전에 XmlReader 메서드가 호출되었습니다. 이 경우 “비동기 작업이 이미 진행 중입니다.” 메시지를 나타내며 InvalidOperationException이 throw됩니다.

예제

다음 예제에서는 현재 노드의 모든 특성을 표시합니다.

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.
}
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

설명

특성을 탐색한 후 요소로 돌아가려면 이 메서드를 사용합니다. 이 메서드는 판독기를 다음 노드 유형 Element``DocumentType``XmlDeclaration중 하나로 이동합니다.

적용 대상