Response.Write("<?xml version=\"1.0\" encoding=\"gb2312\" standalone=\"yes\" ?>");
Response.Write("<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\" xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\">");
Response.Write("<channel>");
Response.Write("<item>");
Response.Write("<title>"+dr["name"].ToString().Trim()+"</title>");
Response.Write("<link>http://www.XXXX.com/search/detail.aspx?id="+dr["jid"].ToString().Trim()+"&type=1"+</link>");
Response.Write("</item>");
Response.Write("</channel>");
Response.Write("</rss>");
Response.ContentType="text/xml";
Response.End();用这样在页面上输出成一个XML文件的样子(dr["xxx"]是DataRow)
但是有个问题
XML里面不支持&符号
在ASPX.NET里面写\&又报错
我在最前面加上@也不行
另外如果数据库里面取出的数据包含<>也会出问题
除了用Replace转换成全角的符号外
有什么办法把它们转义吗?