XPathNodeIterator.Current プロパティ
アセンブリ: System.Xml (system.xml.dll 内)

ノード セットの選択元であるコンテキスト ノードに配置されている XPathNavigator オブジェクト。XPathNodeIterator を選択ノード セットの最初のノードに移動するには、MoveNext メソッドを呼び出す必要があります。

返される XPathNavigator オブジェクトのプロパティを使用すると、現在のノードの情報を取得できます。ただし、返された XPathNavigator オブジェクトは変更しないでください。返された XPathNavigator オブジェクトは、選択したノード セットから移動できません。
変更を加える場合は、XPathNavigator クラスの Clone メソッドを使用して、XPathNavigator オブジェクトを複製してください。複製した XPathNavigator オブジェクトは、選択したノード セットから移動できます。この XPathNavigator オブジェクトの複製メソッドは、XPath クエリのパフォーマンスに影響を与える可能性があります。
SelectAncestors、SelectDescendants、および SelectChildren の各メソッドを実行した結果、ノードが 1 つも選択されていない状態になった場合、Current プロパティはコンテキスト ノードを指しているとは限りません。

XPathNodeIterator オブジェクトの Current プロパティ、および XPathNavigator クラスの Clone メソッドを使用して、Herman Melville の著書のタイトルをすべて取得する例を次に示します。
Dim document As XPathDocument = New XPathDocument("books.xml") Dim navigator As XPathNavigator = document.CreateNavigator() ' Select all books authored by Melville. Dim nodes As XPathNodeIterator = navigator.Select("descendant::book[author/last-name='Melville']") While nodes.MoveNext() ' Clone the navigator returned by the Current property. ' Use the cloned navigator to get the title element. Dim clone As XPathNavigator = nodes.Current.Clone() clone.MoveToFirstChild() Console.WriteLine("Book title: {0}", clone.Value) End While
XPathDocument document = new XPathDocument("books.xml"); XPathNavigator navigator = document.CreateNavigator(); // Select all books authored by Melville. XPathNodeIterator nodes = navigator.Select("descendant::book[author/last-name='Melville']"); while (nodes.MoveNext()) { // Clone the navigator returned by the Current property. // Use the cloned navigator to get the title element. XPathNavigator clone = nodes.Current.Clone(); clone.MoveToFirstChild(); Console.WriteLine("Book title: {0}", clone.Value); }
XPathDocument^ document = gcnew XPathDocument("books.xml"); XPathNavigator^ navigator = document->CreateNavigator(); XPathExpression^ query = navigator->Compile("/bookstore/book"); XPathNodeIterator^ nodes = navigator->Select(query); XPathNavigator^ nodesNavigator = nodes->Current; for each(XPathNavigator^ navigator in nodesNavigator-> SelectDescendants(XPathNodeType::Text, false)) { Console::Write(navigator->Name); Console::WriteLine(navigator->Value); }
この例では、入力として、contosoBooks.xml というファイルを使用しています。
<bookstore xmlns="http://www.contoso.com/books"> <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>

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からXPathNodeIterator.Current プロパティを検索する場合は、下記のリンクをクリックしてください。

- XPathNodeIterator.Current プロパティのページへのリンク