다음을 통해 공유


XPathNodeIterator 클래스

선택된 노드 집합에 대한 반복기를 제공합니다.

네임스페이스: System.Xml.XPath
어셈블리: System.Xml(system.xml.dll)

구문

‘선언
Public MustInherit Class XPathNodeIterator
    Implements ICloneable, IEnumerable
‘사용 방법
Dim instance As XPathNodeIterator
public abstract class XPathNodeIterator : ICloneable, IEnumerable
public ref class XPathNodeIterator abstract : ICloneable, IEnumerable
public abstract class XPathNodeIterator implements ICloneable, IEnumerable
public abstract class XPathNodeIterator implements ICloneable, IEnumerable

설명

XPathNavigator 클래스에서 반환된 XPathNodeIterator 개체는 선택된 노드 집합의 첫 번째 노드에 있지 않습니다. XPathNodeIterator 클래스의 MoveNext 메서드를 호출하여 XPathNodeIterator 개체를 선택된 노드 집합의 첫 번째 노드에 위치시켜야 합니다.

상속자 참고 사항 XPathNodeIterator 클래스에서 상속하는 경우 아래의 멤버를 재정의해야 합니다.

예제

다음 예제에서는 XPathNavigator 클래스의 Select 메서드를 사용하며 XPathNodeIterator 클래스를 통해 노드 집합을 선택합니다.

Dim document As XPathDocument = New XPathDocument("books.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()

Dim nodes As XPathNodeIterator = navigator.Select("/bookstore/book")
Dim nodesNavigator As XPathNavigator = nodes.Current

Dim nodesText As XPathNodeIterator = nodesNavigator.SelectDescendants(XPathNodeType.Text, False)

While nodesText.MoveNext()
    Console.Write(nodesText.Current.Name)
    Console.WriteLine(nodesText.Current.Value)
End While
XPathDocument document = new XPathDocument("books.xml");
XPathNavigator navigator = document.CreateNavigator();

XPathNodeIterator nodes = navigator.Select("/bookstore/book");
XPathNavigator nodesNavigator = nodes.Current;

XPathNodeIterator nodesText = nodesNavigator.SelectDescendants(XPathNodeType.Text, false);

while (nodesText.MoveNext())
{
    Console.Write(nodesText.Current.Name);
    Console.WriteLine(nodesText.Current.Value);
}

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

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

상속 계층 구조

System.Object
  System.Xml.XPath.XPathNodeIterator

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

XPathNodeIterator 멤버
System.Xml.XPath 네임스페이스