You may be approaching this the wrong way, I recently had a problem
going from a dataset to xml and found the columnmapping property of the
dataset in combination with relation objects to work very well
for example:
ds.Relations.Add(new DataRelation("Appsettings AConfiguration",
ds.Tables["Appsettings"].Columns[0],
ds.Tables["AConfiguration"].Columns[0]));
ds.Relations.Add(new DataRelation("Profile Configuration",
ds.Tables["Profile"].Columns[0],
ds.Tables["Configuration"].Columns[1]));
ds.Relations[0].Nested = true;
ds.Relations[1].Nested = true;
ds.Tables["Appsettings"].Columns["ID"].ColumnMapping =
MappingType.Attribute ;
ds.Tables["AConfiguration"].Columns[0].ColumnMapping =
MappingType.Attribute ;
ds.Tables["AConfiguration"].Columns[1].ColumnMapping =
MappingType.Attribute ;
ds.Tables["AConfiguration"].Columns[2].ColumnMapping =
MappingType.Attribute ;
ds.Tables["AConfiguration"].Columns[3].ColumnMapping =
MappingType.SimpleContent ;
ds.Tables["Profile"].Columns["ID"].ColumnMapping =
MappingType.Attribute ;
ds.Tables["Configuration"].Columns[0].ColumnMapping =
MappingType.Attribute ;
ds.Tables["Configuration"].Columns[1].ColumnMapping =
MappingType.Attribute ;
ds.Tables["Configuration"].Columns[2].ColumnMapping =
MappingType.Attribute ;
ds.Tables["Configuration"].Columns[3].ColumnMapping =
MappingType.Attribute ;
ds.Tables["Configuration"].Columns[4].ColumnMapping =
MappingType.SimpleContent ;
the relation objects create the parent child relationship between the
columns, and the nesting property sets it up for use in your XML
document.
the columnmapping stuff is pretty self explanatory.
Hope this helps.
Help! I created a XML schema with a Visual Studio tools. I'm filling a
dataset with a DataAdapter. Before I use the "WriteXml" method to write the
data to a xml file, I want to map the XSD file I created to the dataset so
that when I do use the "WriteXml" method, the generated xml file will be
properly formatted to the schema I created. I did try using the
"ReadXMLSchema" but it didn't work. Please help me!