|
发表于 2020-12-18 16:45:01
|
显示全部楼层
DataTable dt=查询的数据;
//根据News,Markets,Travel,Travel2016条件判断循环的拼字符串
string s="";
for(int i=0;i<dt.Rows.Count;i++ )
{
if(dt.Rows[i]["new"].ToString()=="new")
{
s+="<item>+";
s+="<item Text="+News+" ... >+";
s+="...+";
s+="...+";
s+="</item>";
}
if(dt.Rows[i]["Markets"]=="Markets")
{
s+="<item>+";
s+="<item Text="+Markets+" ... >+";
s+="...+";
s+="...+";
s+="</item>";
}
...
...
}
//用io写xml
StreamWriter sw=new StreamWriter( Server.MapPath("")+"/"+filename+".xml",false,System.Text.Encoding.GetEncoding("GB2312"));
sw.Write(s);
sw.Close(); |
|