XmlReader.MoveToElement 메서드

정의

파생 클래스에서 재정의되는 경우 현재 특성 노드가 포함된 요소로 이동합니다.

public:
 abstract bool MoveToElement();
public abstract bool MoveToElement();
abstract member MoveToElement : unit -> bool
Public MustOverride Function MoveToElement () As 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

설명

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

적용 대상