Mega Code Archive

 
Categories / C# / XML
 

For each style iteration over the nodes in the XmlNode

using System; using System.Collections; using System.Xml; public class Sample {   public static void Main() {     XmlDocument doc = new XmlDocument();     doc.Load("books.xml");     XmlNode root = doc.DocumentElement;     IEnumerator ienum = root.GetEnumerator();     XmlNode book;     while (ienum.MoveNext())      {            book = (XmlNode) ienum.Current;       Console.WriteLine(book.OuterXml);       Console.WriteLine();     }   } }