0
votes

i am parsing a xml file with XPATH

nodes = navigator.Select("/bk:ChaosPlan/bk:SubscriptionInfo",manager);
while (nodes.MoveNext())
        {
            XPathNavigator childNodes = nodes.Current.Clone();
            childNodes.MoveToFirstAttribute();
            string name = childNodes.Value;
            bool x = true;
            x= childNodes.MoveToFirstChild();
            string Id = childNodes.Value;
            subNamenAndId.Add(new Result(name, Id));
            childNodes.MoveToNext();
            certName = childNodes.Value;
            childNodes.MoveToNext();
            templateName = childNodes.Value;

}

but when i am moving to first child (after bool x= true; line) it is returning false and not moving to first child.

what i need to do, Is to get the attribute of first element after running query and then iterate through first 3 child of this element and store those value.

1
Can you show an example Xml document for which this happens?O. R. Mapper

1 Answers

2
votes

When your XPathNavigator is positioned on the attribute call http://msdn.microsoft.com/en-us/library/system.xml.xpath.xpathnavigator.movetoparent.aspx first to be able to then move on to child nodes.