string sql = "SELECT id,name FROM content FOR XML AUTO,XMLDATA"; 
SqlConnection conn =new SqlConnection( System.Configuration.ConfigurationSettings.AppSettings["testDataBase"] ); 
SqlCommand cmd=new SqlCommand(sql,conn); 
conn.Open(); 
XmlTextReader objXmlReader = (XmlTextReader)cmd.ExecuteXmlReader(); 
DataSet ds = new DataSet(); 
ds.DataSetName = "XML"; 
ds.ReadXml(objXmlReader,XmlReadMode.Fragment); 
ds.WriteXml(Server.MapPath("XML.xml")); 
conn.Close(); 

相关文章:

  • 2022-03-11
  • 2022-12-23
  • 2021-07-27
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-23
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
  • 2021-07-11
相关资源
相似解决方案