开发者

synchronization qustion on move XPathNodeIterator and Child XPathNodeIterator [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_如何转开发 Closed 10 years ago.

I created two XPathNodeIterator it and childIt in my code

Code snippet as this,

string selectSfStr = "Equipment/Main/Sub";
            it = nav.Select(selectSfStr);

            while (it.MoveNext())
            {                
                ; // do something here

                if (it.Current.HasChildren)
                {


                    XPathNodeIterator childIt;
                    string selectChildSfStr = "//item";
                    childIt = nav.Select(selectChildSfStr);

                    while (childIt.MoveNext())
                    {
                           ; // do something here, but I found bug. The childIt can't move sychronized with the parent `it`.
                           ;// How can I synchronize `childIt` here when I moved to next `it`.
                    }
                 }
         }

my xml file nested with the sequence of Equipment/Main/Sub/item and there are multi sub nodes and multi item for each of sub nodes


Eventually, I fixed this bug as this,

while (it.MoveNext())
            {                
                // do something here


                if (it.Current.HasChildren)
                {


                    XPathNodeIterator childIt;
                    childIt = null;                    
                    childIt = it.Current.SelectChildren("item", ""); 

                    while (childIt.MoveNext())
                    {
                       // do something here

                       childIt.Current.MoveToParent();
                    }
                }
          }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜