I am looking for help to understand what logic is behind column name in xml file which is generated by DataSet WriteXml() function.
Here is small program which generate xml file by DataSet WriteXml()
List<string> prd = new List<string>();
prd.Add("2010 FYA");
prd.Add("2011 FYA");
prd.Add("2012 FYA");
prd.Add("2013 FYA");
prd.Add("1Q 2014A");
prd.Add("2Q 2014A");
prd.Add("3Q 2014A");
prd.Add("4Q 2014A");
prd.Add("2014 FYA");
DataSet dsQcViewall = new DataSet();
DataTable dtQcViewAllSave = new DataTable();
DataColumn dcSection = new DataColumn();
dcSection.ColumnName = "Section ";
dcSection.DataType = Type.GetType("System.String");
DataColumn dcLi = new DataColumn();
dcLi.ColumnName = "LineItem";
dcLi.DataType = Type.GetType("System.String");
DataColumn dcReviseDate = new DataColumn();
dcReviseDate.ColumnName = "Revise Date";
dcReviseDate.DataType = Type.GetType("System.String");
dtQcViewAllSave.Columns.Add(dcSection);
dtQcViewAllSave.Columns.Add(dcLi);
dtQcViewAllSave.Columns.Add(dcReviseDate);
for (int i = 0; i <= prd.Count-1; i++)
{
DataColumn dcperiod = new DataColumn();
dcperiod.ColumnName = prd[i];
dtQcViewAllSave.Columns.Add(dcperiod);
dcperiod.Dispose();
dcperiod = null;
}
DataRow dr= dtQcViewAllSave.NewRow();
dr["Section "] = "MS";
dr["LineItem"] = "Morgan Stanley";
dr["Revise Date"] = "10-09-2020";
for (int i = 0; i <= prd.Count - 1; i++)
{
dr[prd[i]] = 1200;
}
dtQcViewAllSave.Rows.Add(dr);
dsQcViewall.Tables.Add(dtQcViewAllSave);
dsQcViewall.WriteXml(@"d:\test.xml");
The xml file got generated and from there i got this xml code. please have a look.
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Table1>
<Section_x0020_>MS</Section_x0020_>
<LineItem>Morgan Stanley</LineItem>
<Revise_x0020_Date>10-09-2020</Revise_x0020_Date>
<_x0032_010_x0020_FYA>1200</_x0032_010_x0020_FYA>
<_x0032_011_x0020_FYA>1200</_x0032_011_x0020_FYA>
<_x0032_012_x0020_FYA>1200</_x0032_012_x0020_FYA>
<_x0032_013_x0020_FYA>1200</_x0032_013_x0020_FYA>
<_x0031_Q_x0020_2014A>1200</_x0031_Q_x0020_2014A>
<_x0032_Q_x0020_2014A>1200</_x0032_Q_x0020_2014A>
<_x0033_Q_x0020_2014A>1200</_x0033_Q_x0020_2014A>
<_x0034_Q_x0020_2014A>1200</_x0034_Q_x0020_2014A>
<_x0032_014_x0020_FYA>1200</_x0032_014_x0020_FYA>
</Table1>
</NewDataSet>
1) see this column Section_x0020_
actual column name was Section then why WriteXML function append x0020 after Section
2) see this one <_x0032_010_x0020_FYA>1200</_x0032_010_x0020_FYA>
i have a column 2010 FYA why WriteXml() change it to _x0032_010_x0020_FYA ?
what is logic begin after x0032 and 010 and x0020_
how do i recognize that which column is 2010 FYA ?
which logic WriteXML is using to append x0032 and 010 and x0020_ ?
please help me to understand the column naming convention. thanks