B
briforge
This is my first shot at this, so please be gentle ;-)
I'm simply trying to save and load data for a game. I'm not even sure
at this point that using XML is the best format. Maybe a flat format
is. But I've read more on using XML so I'm trying that first. Here's
what I've got so far:
DataSet ds = new DataSet("CurrentGame");
DataTable playersTable = ds.Tables.Add("players");
playersTable.Columns.Add("name", Type.GetType("System.String"));
playersTable.Columns.Add("playerType", Type.GetType("System.Int32"));
playersTable.Columns.Add("playerNum", Type.GetType("System.Int32"));
playersTable.Columns.Add("charPiece", Type.GetType("System.Int32"));
DataRow row;
foreach (Player player in players)
{
row = playersTable.NewRow();
row["name"] = player.getName();
row["playerType"] = (int) player.getPlayerType();
row["playerNum"] = (int) player.getPlayerNum();
row["charPiece"] = (int) player.getCharPiece();
}
ds.WriteXml(getFullPath("NewGame.xml"));
The file is being written, but the only output is <CurrentGame/>. What
am I doing wrong?
Thanks
I'm simply trying to save and load data for a game. I'm not even sure
at this point that using XML is the best format. Maybe a flat format
is. But I've read more on using XML so I'm trying that first. Here's
what I've got so far:
DataSet ds = new DataSet("CurrentGame");
DataTable playersTable = ds.Tables.Add("players");
playersTable.Columns.Add("name", Type.GetType("System.String"));
playersTable.Columns.Add("playerType", Type.GetType("System.Int32"));
playersTable.Columns.Add("playerNum", Type.GetType("System.Int32"));
playersTable.Columns.Add("charPiece", Type.GetType("System.Int32"));
DataRow row;
foreach (Player player in players)
{
row = playersTable.NewRow();
row["name"] = player.getName();
row["playerType"] = (int) player.getPlayerType();
row["playerNum"] = (int) player.getPlayerNum();
row["charPiece"] = (int) player.getCharPiece();
}
ds.WriteXml(getFullPath("NewGame.xml"));
The file is being written, but the only output is <CurrentGame/>. What
am I doing wrong?
Thanks