[C#] xml Parsing GetElementsByTagName

XmlDocument doc = new XmlDocument(); doc.Load(“Book.xml”); XmlNodeList node = doc.GetElementsByTagName(“Books”); for (int i = 0; i < node.Count; i++) //방법1 { Console.WriteLine(node.Item(i).SelectSingleNode(“Name”).InnerText); } foreach (XmlNode node in node)//방법2 { Console.WriteLine(node.SelectSingleNode(“Name”).InnerText); }

c# List

using System; using System.Collections.Generic; class Program { static void Main() { List list = new List(); list.Add(2); list.Add(3); list.Add(7); foreach (int prime in list) // Loop through List with foreach { Console.WriteLine(prime); } for (int i = 0; i < list.Count; i++) // Loop through List with for { Console.WriteLine(list[i]); } } }