c# - save a dataset object to XML -
hi have code in reading excel sheet storing in dataset , displaying output, want save whatever ds.getxm() method in .xml format.(eg : output.xml)
daadapter = new oledbdataadapter("select * [sheet1$]", connection); system.data.datatable dt=new system.data.datatable("childelement"); //daadapter.fillschema(dt, schematype.source); daadapter.fill(dt); dataset ds = new dataset("rootelement"); ds.tables.add(dt); console.writeline(ds.getxml()); console.read();
super simple approach:
system.io.file.writealltext(@"c:\temp\myfile.xml", ds.getxml());
from msdn:
creates new file, writes specified string file, , closes file. if target file exists, overwritten.
Comments
Post a Comment