SqlConnection conn =new SqlConnection( System.Configura">

从数据库中读取数据自动生成XML

80酷酷网    80kuku.com

  xml|生成xml|数据|数据库Program Ex:
=================

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();















分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间

上一篇XML里的非法字符

下一篇XML解析

点击: