thanks for the help, appreciated.
i had some time to play around with this today and came up with an alternative to your suggestions which does what i need.
assuming that the people.xml has been saved to a file.
XML file :
<people>
<location>
<list name="ben" surname="gunn" location="peru" dwelling="house"/>
<list name="tom" surname="cruise" location="miami" dweliing="condo"/>
</location>
</people>
Code:
String fname = "people.xml";
XmlDocument mypeople = new XmlDocument();
FileStream Fstream = null;
if (File.Exists(fname))
{
try
{
Fstream = new FileStream(fname,
FileMode.Open,
FileAccess.Read);
// Open the XML file
mypeople.Load(Fstream);
}
finally
{
Fstream.Close();
}
}
XmlNodeList people = mypeople.GetElementsByTagName("list");
int pad = 10; //pad spacing value
Console.WriteLine(" =-= People=-=");
Console.WriteLine(
"Name".PadRight(pad, '-') +
"Surname".PadRight(pad, '-') +
"Location".PadRight(pad, '-') +
"Dwelling".PadRight(pad, '-')
);
foreach (XmlNode attr in people)
{
Console.WriteLine(
"{0} {1} {2} {3} ",
attr.Attributes["name"].InnerText.PadLeft(pad,'-'),
attr.Attributes["surname"].InnerText.PadLeft(pad, '-'),
attr.Attributes["location"].InnerText.PadLeft(pad,'-'),
attr.Attributes["dwelling"].InnerText.PadLeft(pad,'-'),
);
}
Console.ReadKey();
}
ignore the pad statement was messing with alignment on console. but this does achieve the desired effect.
just have to get it into a gridview in ASP.net now
Hope this helps someone else out.