我有两个 RSS 提要,我想合并在一起制作一个。我实际上已经设法将两个提要合并在一起并将项目放置在正确的位置 - 但是每个属性中的数据,即标题包含标题+链接+描述+作者+pubDate - 并且对于链接、描述、作者和发布日期重复. 有人可以帮我调试它吗?
Object rssData = new object();
Cms.UI.CommonUI.ApplicationAPI AppAPI = new Cms.UI.CommonUI.ApplicationAPI();
rssData = AppAPI.ecmRssSummary(50, true, "DateCreated", 0, "");
Response.ContentType = "text/xml";
Response.ContentEncoding = System.Text.Encoding.UTF8;
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(rssData.ToString());
//************************************************************
// Obtain 5 data items from second list
Object rssData1 = new object();
Cms.UI.CommonUI.ApplicationAPI AppAPI1 = new Cms.UI.CommonUI.ApplicationAPI();
rssData1 = AppAPI1.ecmRssSummary(60, true, "DateCreated", 5, "");
XmlDocument xmlDocument1 = new XmlDocument();
xmlDocument1.LoadXml(rssData1.ToString());
XmlNodeList nl = xmlDocument1.SelectNodes("/rss/channel");
XmlNode root = nl[0]; //do I need this line?
foreach (XmlNode xnode1 in root.ChildNodes)
{
string title = xnode1.InnerText;
string link = xnode1.InnerText;
string desc = xnode1.InnerText;
string auth = xnode1.InnerText;
string pdate = xnode1.InnerText;
//Merge new nodes
node = xmlDocument.CreateNode(XmlNodeType.Element, "item", null);
//node.InnerText = "this is new node";
//create title node
XmlNode nodeTitle = xmlDocument.CreateElement("title");
nodeTitle.InnerText = title;
//create Link node
XmlNode nodeLink = xmlDocument.CreateElement("link");
nodeLink.InnerText = link;
XmlNode nodeDesc = xmlDocument.CreateElement("description");
nodeDesc.InnerText = desc;
XmlNode nodeAuthor = xmlDocument.CreateElement("author");
nodeAuthor.InnerText = auth;
XmlNode nodepubDate = xmlDocument.CreateElement("pubDate");
nodepubDate.InnerText = pdate;
//add to parent node
node.AppendChild(nodeTitle);
node.AppendChild(nodeLink);
node.AppendChild(nodeDesc);
node.AppendChild(nodeAuthor);
node.AppendChild(nodepubDate);
//add to elements collection
//xmlDocument.DocumentElement.AppendChild(node);
xmlDocument.DocumentElement.SelectNodes("/rss/channel")[0].AppendChild(node);
}
//********************************************
xmlDocument.Save(Response.Output);