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.

http://msdn.microsoft.com/en-us/library/ms143375.aspx


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -