How can I iterate though each child node in an XML file?

后端 未结 7 864
说谎
说谎 2021-01-04 00:49

I have an XML File and i would like to iterate though each child node gathering information.

Here is my C# code it only picks up one node, the FieldData i would like

7条回答
  •  醉梦人生
    2021-01-04 01:32

    Or you use recursion:

        public void findAllNodes(XmlNode node)
        {
            Console.WriteLine(node.Name);
            foreach (XmlNode n in node.ChildNodes)
                findAllNodes(n);
        }
    

    Where do you place the payload depends on what kind of search you want to use (e.g. breadth-first search, depth-first search, etc; see http://en.wikipedia.org/wiki/Euler_tour_technique)

提交回复
热议问题