hey guys ,
I have 4 orders and the following code iterates and prints out the each of the values.
At the end it has reached the last order.

My problem : i would like to come back to the first order. ie. i would like to set the ni at the first order again.

i could find any method where i could spring back to the first element.

any help would be appreciated.

XPathNodeIterator ni = nav.Select("/orders/order");
while (ni.MoveNext())      
  Console.WriteLine(ni.Current.Value);

I've no clue about XMLPathNavigator, but I see XPathNodeIterator like DataReader (Forward, and readonly) it means you can't return back to first element so the solution is to refill ni again

XPathNodeIterator ni = nav.Select("/orders/order");
while (ni.MoveNext())      
Console.WriteLine("First time " + ni.Current.Value); 
ni = nav.Select("/orders/order");
while (ni.MoveNext())      
Console.WriteLine("Second time " + ni.Current.Value);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.