I'm creating an xml file from some data and I'm geting repeating parent
nodes in the xml file. Not sure where I'm going wrong?
<?xml version="1.0" standalone="yes "?>
<MyTestData xmlns="http://www.mytestdata. com/list_data.xsd">
<Wigets>
<Wiget>Muffle r Bearing</Wiget>
</Wigets>
<Wigets>
<Wiget>5 gallons of prop wash</Wiget>
</Wigets>
<Wigets>
<Wiget>gonkalat or armature</Wiget>
</Wigets>
<Gizmos>
<Gizmo>hole-mover</Gizmo>
</Gizmos>
<Gizmos>
<Gizmo>bulkhe ad remover</Gizmo>
</Gizmos>
</MyTestData>
ArrayList alWigets = new ArrayList();
ArrayList alGizmos = new ArrayList();
alWigets.Add("M uffler Bearing");
alWigets.Add("5 gallons of prop wash");
alWigets.Add("g onkalator armature");
alGizmos.Add("h ole-mover");
alGizmos.Add("b ulkhead remover");
DataSet ds = new DataSet("MyTest Data");
ds.Namespace = "http://www.mytestdata. com/list_data.xsd";
DataTable dtWigets = new DataTable("Wige ts");
DataTable dtGizmos = new DataTable("Gizm os");
dtWigets.Column s.Add("Wiget");
dtGizmos.Column s.Add("Gizmo");
string[] myWiget = new string[1];
string[] myGizmo = new string[1];
for (int i = 0;i < alWigets.Count; i++)
{
myWiget[0] = alWigets[i].ToString();
dtWigets.Rows.A dd(myWiget);
}
for (int i = 0;i < alGizmos.Count; i++)
{
myGizmo[0] = alGizmos[i].ToString();
dtGizmos.Rows.A dd(myGizmo);
}
ds.Tables.Add(d tWigets);
ds.Tables.Add(d tGizmos);
ds.WriteXml("st uff.xml");