Not sure exactly why and how you want to apply your logic, but your code can run alternatively as below too:
string strOutput="<Store><Person>John</Person><Item>Pen</Item><Amount>4</Amount></Store>";
string Path = Server.MapPath("~/Data/test.xml");
FileStream fs = new FileStream(Path,FileMode.OpenOrCreate,FileAccess.R eadWrite);
StreamWriter writer = new StreamWriter(fs);
writer.Write(strOutput);
writer.Close();
fs.Close();
XmlDataDocument xdd = new XmlDataDocument();
xdd.DataSet.ReadXmlSchema(Path);
DataGrid1.DataSource = xdd.DataSet;
DataGrid1.DataBind();
Regards
Mike
Fortune favours the brave, so don't regret on missed oppurtunities.
|