I've created a XPathNodeIterator that contains a few short XML segments (each with a file description):
XPathNodeIterator segments = node.SelectDescendants("Segment", node.NamespaceURI, false);
Now, when trying to loop them, it seems that only the first segment is picked every time. Here are two versions of the loops I've tried (File/Files classes only for example):
while (segments.MoveNext())
{
File f = GetSingleFileDataFromSegment(segments.Current);
files.Add(f);
}
Another try:
foreach (XPathNavigator seg in segments)
{
File f = GetSingleFileDataFromSegment(seg);
files.Add(f);
}
When viewing a single segment in a loop with Watch or Quickwatch, it looks as it should, all different segments are selected one at a time - but end result is that "files" contain multiple copies of the first segment.
Is this normal behavior with XPathNodeIterator? Or is something missing here? I'm currently using .NET Framework 3.5.