各位大哥!如何用递归把DataSet中的数据生成XML文件呢? 大哥帮帮小弟吧,我从来没接触过XML啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 别说没人顶嘛:-)这个你看看SDK文档就知道了 讲清楚点,你的数据库结构是怎么样的?想生成什么格式的XML? 下面是两个有关如何将 DataSet 的 XML 表示形式写入文件的示例。第一个示例将所生成的 XML 的文件名当作字符串传递到 WriteXml。第二个示例传递一个 System.IO.StreamWriter 对象。[Visual Basic]custDS.WriteXml("Customers.xml", XmlWriteMode.WriteSchema)[C#]custDS.WriteXml("Customers.xml", XmlWriteMode.WriteSchema);[Visual Basic]Dim xmlSW As System.IO.StreamWriter = New System.IO.StreamWriter("Customers.xml")custDS.WriteXml(xmlSW, XmlWriteMode.WriteSchema)xmlSW.Close()[C#]System.IO.StreamWriter xmlSW = new System.IO.StreamWriter("Customers.xml");custDS.WriteXml(xmlSW, XmlWriteMode.WriteSchema);xmlSW.Close(); 楼上两位大哥说的只是直接装DS导出到XML中,我试了,可以,但,递归不出来啊 ds.WriteXml(Server.MapPath(Path)) ds.Clear() ds.Dispose() 要生成XML文件,但是涉及到的是把数据库中存在的无限级用递归的方法输出,当然,可以用不DataSet用SqlDatareader也行!普通情况下生成XML我也实现! 递归的话,getxml没有这么智能,你得自己生成XML,主要在DATASET的表中ID与ParentID中建立关系,然后递归生成XML 没那么复杂,你先用递归生成xml字符串,然后写文件就可以了 private void CreateMetoneTree(){ xmlDoc_Metone = new XmlDocument(); new Town.Com.MobileServiceTypeCollection().GetMetoneTree(out ds); //生成根节点 XmlElement treeContentElement = xmlDoc_Metone.CreateElement("NewDataSet"); xmlDoc_Metone.AppendChild(treeContentElement); //递归生成频道的XML文档 for(int j=0;j<ds.Tables["Tree"].Rows.Count;j++) { if(Int32.Parse(ds.Tables["Tree"].Rows[j].ItemArray[2].ToString()) == 0) { this.BulidXmlTree(treeContentElement,j); } else { continue; } } string fileName = Server.MapPath("Xml/MetoneTree.xml"); xmlDoc_Metone.Save(fileName);} 怎么利用ajaxpro做一个动态的进度工具? 安装VS asp.net用了<asp:login>控件后,无法清空文本框 问个T4模板的问题 AJAX无刷新翻页 用ScriptManager可以实现么 ASP.NET,怎样插入activex控件? 如何把文件夹下的图片显示在DATAGRID中? 启动程序时报错 用户控件的问题 请求帮助:ajax调用后台方法返回页面显示为undefined 我的递归遍历,怎么只有两层 怎么样用session或cookie 保存mssql语句select选中的值
[Visual Basic]
custDS.WriteXml("Customers.xml", XmlWriteMode.WriteSchema)
[C#]
custDS.WriteXml("Customers.xml", XmlWriteMode.WriteSchema);
[Visual Basic]
Dim xmlSW As System.IO.StreamWriter = New System.IO.StreamWriter("Customers.xml")
custDS.WriteXml(xmlSW, XmlWriteMode.WriteSchema)
xmlSW.Close()
[C#]
System.IO.StreamWriter xmlSW = new System.IO.StreamWriter("Customers.xml");
custDS.WriteXml(xmlSW, XmlWriteMode.WriteSchema);
xmlSW.Close();
ds.Clear()
ds.Dispose()