/// <summary> /// 取得聚合文章 /// </summary> /// <returns></returns> public string GetRSS() { CMS.BLL.JopManage jm = new CMS.BLL.JopManage();//自己的业务类 jm.SortField = "createTime desc"; ArrayList al = jm.GetAll();//根据类别得到数据 StringBuilder strCode = new StringBuilder(); strCode.Append("<?xml version=/"1.0/" encoding=/"utf-8/" standalone=/"yes/" ?>"); strCode.Append("<RSS version=/"2.0/" xmlns:dc=/"http://purl.org/dc/elements/1.1//""); //strCode.Append(" xmlns:trackback=/"http://madskills.com/public/xml/RSS/module/trackback//" "); strCode.Append(" xmlns:sy=/"http://purl.org/RSS/1.0/modules/syndication//" xmlns:slash=/"http://purl.org/RSS/1.0/modules/slash//">"); strCode.Append("<channel>"); strCode.Append("<title>XML聚合</title>"); strCode.Append("<link>http://" + Request.ServerVariables["SERVER_NAME"] + "</link>"); strCode.Append("<description>XML聚合</description> "); strCode.Append("<copyright>Copyright 2005</copyright> "); foreach (CMS.Model.CMS_JobT jt in al) { string Id = jt.id.ToString(); string title = CMS.BLL.PubClass.GetCompanyName(jt.companyID)+"-"+jt.name; string addr = CMS.BLL.PubClass.GetArea(jt.workCity); string description = jt.content; string pubdate = jt.createTime.ToString(); strCode.Append("<item>"); strCode.Append("<title>" + title + "</title>"); strCode.Append("<link>http://" + Request.ServerVariables["SERVER_NAME"] + "//jobSearch/JobSearch.aspx?jobid=" + Id + "</link>"); strCode.Append("<PubDate>" + pubdate + "</PubDate>"); strCode.Append("<description><!--[CDATA[" + description + "]]--></description>"); strCode.Append("</item>"); } strCode.Append("</channel>"); strCode.Append("</RSS>"); return strCode.ToString(); } private void WriteRSS(string pathfilename) { try { FileInfo finfo = new FileInfo(pathfilename); using (FileStream fs = finfo.OpenWrite()) { StreamWriter sw = new StreamWriter(fs,System.Text.Encoding.GetEncoding("UTF-8")); sw.WriteLine(this.GetRSS()); sw.Flush(); sw.Close(); } //return true; } catch (System.Exception ex) { System.Web.HttpContext.Current.Response.Write(ex.Message); // return false; throw; }