XPathNavigator.MoveToNextAttribute 메서드

정의

파생 클래스에서 재정의되면 XPathNavigator를 다음 특성으로 이동합니다.

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

반환

XPathNavigator가 다음 특성으로 이동하면 true이고, 더 이상 특성이 없으면 false입니다. false이면 XPathNavigator의 위치가 변경되지 않습니다.

예제

다음 예제에서는 및 MoveToNextAttribute 메서드를 MoveToFirstAttribute 사용하여 파일의 각 책에 books.xml 대한 모든 특성을 표시합니다.

  XPathDocument^ document = gcnew XPathDocument("books.xml");
  XPathNavigator^ navigator = document->CreateNavigator();

  // Select all book nodes and display all attributes on each book.
  XPathNodeIterator^ nodes = navigator->SelectDescendants("book", "", false);
  while (nodes->MoveNext())
  {
      XPathNavigator^ navigator2 = nodes->Current->Clone();
      navigator2->MoveToFirstAttribute();
      Console::WriteLine("{0} = {1}", navigator2->Name, navigator2->Value);

      while (navigator2->MoveToNextAttribute())
      {
          Console::WriteLine("{0} = {1}", navigator2->Name, navigator2->Value);
      }

      Console::WriteLine();
  }
XPathDocument document = new XPathDocument("books.xml");
XPathNavigator navigator = document.CreateNavigator();

// Select all book nodes and display all attributes on each book.
XPathNodeIterator nodes = navigator.SelectDescendants("book", "", false);
while (nodes.MoveNext())
{
    XPathNavigator navigator2 = nodes.Current.Clone();
    navigator2.MoveToFirstAttribute();
    Console.WriteLine("{0} = {1}", navigator2.Name, navigator2.Value);

    while (navigator2.MoveToNextAttribute())
    {
        Console.WriteLine("{0} = {1}", navigator2.Name, navigator2.Value);
    }

    Console.WriteLine();
}
Dim document As XPathDocument = New XPathDocument("books.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()

' Select all book nodes and display all attributes on each book.
Dim nodes As XPathNodeIterator = navigator.SelectDescendants("book", "", False)
While nodes.MoveNext()
    Dim navigator2 As XPathNavigator = nodes.Current.Clone()
    navigator2.MoveToFirstAttribute()
    Console.WriteLine("{0} = {1}", navigator2.Name, navigator2.Value)

    While navigator2.MoveToNextAttribute()
        Console.WriteLine("{0} = {1}", navigator2.Name, navigator2.Value)
    End While

    Console.WriteLine()
End While

이 예제에서는 books.xml 파일을 입력으로 사용합니다.

<?xml version="1.0" encoding="utf-8" ?>   
<bookstore>  
    <book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">  
        <title>The Autobiography of Benjamin Franklin</title>  
        <author>  
            <first-name>Benjamin</first-name>  
            <last-name>Franklin</last-name>  
        </author>  
        <price>8.99</price>  
    </book>  
    <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">  
        <title>The Confidence Man</title>  
        <author>  
            <first-name>Herman</first-name>  
            <last-name>Melville</last-name>  
        </author>  
        <price>11.99</price>  
    </book>  
    <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">  
        <title>The Gorgias</title>  
        <author>  
            <name>Plato</name>  
        </author>  
        <price>9.99</price>  
    </book>  
</bookstore>  

설명

XPathNavigator 가 현재 특성에 배치되지 않은 경우 이 메서드는 를 반환 false 하고 의 위치는 XPathNavigator 변경되지 않습니다.

XPathNavigator 특성에 배치되면 메서드 MoveToNext, MoveToPreviousMoveToFirst 메서드를 적용할 수 없습니다. 이러한 메서드는 항상 를 반환 false 하고 의 XPathNavigator위치를 변경하지 않습니다.

XPathNavigator 가 특성에 배치되면 를 호출 MoveToParent 하여 소유자 요소로 이동할 수 있습니다.

적용 대상

추가 정보