using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NIBM.DAL;
using System.Data;
using System.Xml;
namespace NIBM.SysWeb {
public partial class form : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
SQLDAL dal = new SQLDAL();
DataSet ds = dal.GetList("*", "TSvr_VPS_VerifyInfo", "VerifySeq=10", "");
XmlDocument doc = new XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", null));
XmlElement root = doc.CreateElement("Apply");
doc.AppendChild(root);
foreach (DataRow dr in ds.Tables[0].Rows) {
for (int i = 0;i<dr.Table.Columns.Count; i++) //列数
{
XmlElement child = doc.CreateElement(dr.Table.Columns[i].ColumnName);
XmlAttribute attr = doc.CreateAttribute("value");
attr.Value = dr.ItemArray[i].ToString();
child.Attributes.Append(attr);
root.AppendChild(child);
}
string xmlString = doc.OuterXml;
doc.Save(@"C:\PrintXML.xml"); //保存xml文件,取名为PrintXML.xml
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NIBM.DAL;
using System.Data;
using System.Xml;
namespace NIBM.SysWeb {
public partial class form : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
SQLDAL dal = new SQLDAL();
DataSet ds = dal.GetList("*", "TSvr_VPS_VerifyInfo", "VerifySeq=10", "");
XmlDocument doc = new XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", null));
XmlElement root = doc.CreateElement("Apply");
doc.AppendChild(root);
foreach (DataRow dr in ds.Tables[0].Rows) {
for (int i = 0;i<dr.Table.Columns.Count; i++) //列数
{
XmlElement child = doc.CreateElement(dr.Table.Columns[i].ColumnName);
XmlAttribute attr = doc.CreateAttribute("value");
attr.Value = dr.ItemArray[i].ToString();
child.Attributes.Append(attr);
root.AppendChild(child);
}
string xmlString = doc.OuterXml;
doc.Save(@"C:\PrintXML.xml"); //保存xml文件,取名为PrintXML.xml
}
}
}
}