How To Put Data From DataView To XML File in C# Web Application?
i am reading data fro开发者_开发百科m the XML file and putting it in to data set as,
public DataSet GetProductsLive()
{
try
{
string XMLPath = /*rver.MapPath(*/@"c:\LiveData.xml";
DataSet dsStore = new DataSet();
dsStore.ReadXml(XMLPath);
return dsStore;
}
catch (Exception ex)
{
return null;
}
}
but now i want to put data from DataView to the new created XML file then how would i do it?
You can easily do that, just use DataSet.WriteXml method see full sample on msdn
public void SaveProductsLive(DataSet ds)
{
string XMLPath = /*rver.MapPath(*/@"c:\LiveData.xml";
ds.WriteXml(XMLPath, XmlWriteMode.WriteSchema);
}
It's work
Dataset dataset = New DataSet();
if (dataset .Tables.Count > 0)
{
dataset .WriteXml("file.xml");
}
hopefully can help you!
精彩评论