How to set change DataSet Name when Exporting to XML using WriteXml function

Amit
 
on Jan 21, 2013 02:40 AM
2958 Views

i m using this function to to export xml

It is working fing but
I want to change  <NewDataSet showing in output to something else say <xyz>.
 


public void ConnectionXML()
{
 
SqlCommand command = new SqlCommand();
command.CommandText = "SELECT * FROM test5";
command.CommandType = CommandType.Text;
command.Connection = con;
SqlDataAdapter da = new SqlDataAdapter(command);
DataSet ds = new DataSet();
da.Fill(ds,"Url");
// Get a StreamWriter object
StreamWriter xmlDoc = new StreamWriter(Server.MapPath("~/xmlfile.xml"), true );
 
// Apply the WriteXml method to write an XML document
ds.WriteXml(xmlDoc);
xmlDoc.Close();
 
}

 

<?xml version="1.0" encoding="UTF-8" ?>
- <strong><NewDataSet></strong>
- <Url>
  <link>amit.aspx</link>
  </Url>
- <Url>
  <link>amit1.aspx</link>
  </Url>
- <Url>
  <link>amit2.aspx</link>
  </Url>
<strong> </NewDataSet></strong>

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Mudassar
 
on Jan 21, 2013 03:41 AM

You can set DataSet Name as

ds.DataSetName = "MyDataSet";