Xml ファイルを解析しています。XPathNodeIterator
MoveNext()
C#2.0でもっと合理的に使う方法に困った。
このような私のコード、
while (it.MoveNext())
{
string str = it.Current.GetAttribute("id", it.Current.NamespaceURI);
it.Current.MoveToChild("item", "");
// do someting....
// My XMl file is a complex Xml file. I must Move to multi layer Child with *MoveToChild()*.
// After that, I must add several *MoveToParent()* in different Layers to make sure the *it* still meet for the use of while loop.
// I think it doesn't make sense like this.
// Some time. the *it* can't still direct to my original layer. While-Loop doesn't work well.
}
新しい XPathNodeIterator オブジェクトtempItを次のように宣言しようとしましたが、
while (it.MoveNext())
{
XPathNodeIterator tempIt;
tempIt= it;
string str = tempIt.Current.GetAttribute("id", tempIt.Current.NamespaceURI);
tempIt.Current.MoveToChild("item", "");
// Now I chech *it* on here, I found the *it* also changed it's *current* and "position". and it's count also changed.
// I don't know why.
}
この問題を解決するにはどうすればよいですか?
コメントや提案に感謝します。