XPathNodeIterator.AsEnumerable

namespace Foo

open System.Xml.XPath

[<AutoOpen>]
module FsExtensions =

    type XPathNodeIterator with
        /// Converts an XPathNodeIterator into a seq{XPathNavigator}.
        member this.AsEnumerable =
            this |> Seq.unfold (fun it -> match it.MoveNext() with
                                          | false -> None 
                                          | true -> Some(it.Current, it))
Example:
for x in iterator.AsEnumerable do
    // something

Description

Exposes an XPathNodeIterator as an IEnumerable<XPathNavigator> for easy looping.

Details

Double click on the code to select all.

 

;