views:

113

answers:

1

I have a C# application that calls a stored procedure that produces an xml result (using FOR XML Explicit) that I want to save to disk. Doing some research I have found the following method:

var data = new DataSet();
XmlReader reader = cmd.ExecuteXmlReader();
data.ReadXmlSchema(reader);
data.ReadXml(reader, XmlReadMode.Fragment);
data.WriteXml(filename);

However this outputs the following in the file:

<?xml version="1.0" standalone="yes" ?> 
  <NewDataSet />

I think this method might only work for XML Raw and XML Auto however I can look through the dataset's tables and see the data is there.

UPDATE: I was able to get it to work by not reading the XmlSchema and by not specifying the XmlReadMode.

A: 

I was able to get it to work by not reading the XmlSchema and by not specifying the XmlReadMode.

jwarzech