create xml from all rows in database
i am trying to find a handier way of creating an xml file containing a selection of tables/ all tables? i a开发者_高级运维m using a typed dataset so reading all the rows into the dataset with an tableadapter would be an option.
The DataSet
class has a method GetXML()
, so if you load all the data you need into your typed DataSet, that should be pretty much all you need.
From MSDN: http://msdn.microsoft.com/en-us/library/zx8h06sz.aspx
GetXml returns the XML representation of the DataSet without schema information. To write the schema information from the DataSet (as XML Schema) to a string, use GetXmlSchema.
To write a DataSet to a file, stream, or XmlWriter, use the WriteXml method. The first parameter you pass to WriteXml is the destination of the XML output. For example, pass a string containing a file name, a System.IO.TextWriter object, and so on. You can pass an optional second parameter of an XmlWriteMode to specify how the XML output is to be written.
精彩评论