I'm creating a program using C# that makes an XML file.
It uses dataset for writing, but there's one thing I'm not sure how to do.
I want the output like this...<Name> </Name>
But now its getting like this...<Name/>
Here is my Code
private void btnXML_Click(object sender, RoutedEventArgs e){
DataSet ds = CreateDynamicDataSet();
ds.WriteXml(@"C:\Test\xmlfile.xml");
}
private DataSet CreateDynamicDataSet()
{
DataSet ds = new DataSet("DS");
ds.Namespace = "StdNamespace";
DataTable stdTable = new DataTable("Student");
DataColumn col1 = new DataColumn("Name");
DataColumn col2 = new DataColumn("Address");
stdTable.Columns.Add(col1);
stdTable.Columns.Add(col2);
ds.Tables.Add(stdTable);
//Add student Data to the table
DataRow newRow; newRow = stdTable.NewRow();
newRow["Name"] = "Nila";
newRow["Address"] = "Meadowlake Dr, Dtown";
stdTable.Rows.Add(newRow);
newRow = stdTable.NewRow();
newRow["Name"] = "";
newRow["Address"] = "NewYork";
stdTable.Rows.Add(newRow);
newRow = stdTable.NewRow();
newRow["Name"] = "Mike Gold";
newRow["Address"] = "New York";
stdTable.Rows.Add(newRow);
ds.AcceptChanges();
return ds;
}
<?xml version="1.0" standalone="yes"?>