Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

XPathNodeIterator.Current Property

When overridden in a derived class, gets the XPathNavigator object for this XPathNodeIterator, positioned on the current context node.

Namespace:  System.Xml.XPath
Assembly:  System.Xml (in System.Xml.dll)

abstract Current : XPathNavigator with get

Property Value

Type: System.Xml.XPath.XPathNavigator
An XPathNavigator object positioned on the context node from which the node set was selected. The MoveNext method must be called to move the XPathNodeIterator to the first node in the selected set.

You can use the properties of the returned XPathNavigator object to obtain information on the current node. However, the returned XPathNavigator object should not be modified. The returned XPathNavigator object cannot be moved away from the selected node set.

Alternatively, you can clone the XPathNavigator object using the Clone method of the XPathNavigator class. The cloned XPathNavigator object can then be moved away from the selected node set. This method of cloning the XPathNavigator object might affect the performance of the XPath query.

If the SelectAncestors, SelectDescendants, and SelectChildren methods result in no nodes being selected, the Current property might not be pointing to the context node.

To test whether nodes have been selected, use the Count property as shown in the following example.

The following example gets all book titles authored by Herman Melville using the Current property of the XPathNodeIterator object and the Clone method of the XPathNavigator class.

No code example is currently available or this language may not be supported.

The example takes the contosoBooks.xml file as input.

<?xml version="1.0" encoding="utf-8" ?>
<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>
    <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">
        <title>The Confidence Man</title>
    <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">
        <title>The Gorgias</title>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft