Hi,
I have an xml file with structured like this:
<?xml version="1.0" encoding="UTF-8"?>
<Soldiers>
<Soldier name="Billy Smith" rank="Private" serial="34" />
(a bunch more soldiers)
</Soldiers>
In my program, I have a struct:
public struct soldierStruct
{
public string name;
public string rank;
public string serial;
}
I would like to make a loop that reads however many XML-soldiers there
are into an ArrayList of struct-soldiers. I can come up with the
framework for it, it's just the reading attributes part that I don't
understand how to do. Can anyone help?
Thanks for any suggestions,
cdj
===============
Framework:
public ArrayList GetSoldiers()
{
ArrayList soldiers= new ArrayList();
soldiers.clear();
XmlTextReader reader = new XmlTextReader(path + filename);
reader.Read();
while (reader.Read())
{
soldierStruct sol;
//Stuff here to make sure the reader is
where
//it's supposed to be?????
sol.name = ????? //Need attribute help
somewhere around here
sol.rank = ??????
sol.serial = ??????
soldiers.add(sol)
}
return soldiers;
}