This piece of code opens an xml file containing a list of IP addresses.
If it finds elements, it will load the element values into an ArrayList.
ArrayList ips = new ArrayList();
XmlTextReader reader = new XmlTextReader(@"C:\inetpub\wwwroot\addressbook\iplist.xml");
// Read the Start Element
reader.ReadStartElement("ip_list");
// Read an attribute
reader.Read();
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an element.
Console.Write("<" + reader.Name);
Console.WriteLine(">");
break;
case XmlNodeType.Text: //Display the text in each element.
ips.Add(reader.Value);
break;
case XmlNodeType. EndElement: //Display the end of the element.
Console.Write("" + reader.Name);
Console.WriteLine(">");
break;
}
}