On Thu, 26 May 2005 09:32:45 -0700, hari patel via .NET 247
<an*******@dotnet247.com> wrote:
hieee there,
I am in big trouble. I want to export data from Dataset or Datagrid to .txt file using XML in VB.NET and I want to do it Manually but I don't have any ideas because I am new To XML. Please help me and Reply me Soon. Thank you in Advance.
--------------------------------
From: Hari Patel
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>WLGv4s1atUa6gMUQisKPnw==</Id>
Not sure what you mean here. there are 2 possibilities, though.
(My apologies, these examples are in C#, but the fundamentals are the
same - Also, they have not been sanity checked, purely because it is
nearly time to go home. ;o) )
1) Dataset.WriteXml("filename.txt",XmlFileMode)
or
2)
string output = "<?xml version=\"1.0\"">;
foreach(DataRow myRow in Dataset.Tables[0].Rows){
output += "<row>";
foreach(DataColumn myColumn in DataSet.Tables[0].Columns){
output += "<" + myColumn.ColumnName + ">" + _
myRow[myColumn].ToString() + "</" + myColumn.ColumnName + ">";
}
output += "</Row>";
}
then save "output" to the file.
HTH