私は CMS を使用しており、フォルダー内のコンテンツから RSS フィードを生成する機能を見つけました。ただし、リストから行の1つを削除したいと思います。私は調査を行いましたが、不要な行を削除するために XmlDocument クラスを使用する必要があると「考えています」。Firebug と FirePath を使用して XPath を取得しましたが、適切に適用する方法がわかりません。.Load と .LoadXml のどちらを使用する必要があるかもわかりません。フィードが正常に表示されるかのように、後者を使用しました。ただし、そのオーバーロードされた一致エラーを取り除くために ToString() を変換する必要がありました....
削除したい行は「Archived Planes」と呼ばれ、FirePath で取得した XPath は「.//*[@id='feedContent']/xhtml:div[11]/xhtml:h3/xhtml:a」です。
また、 .RemoveChild(node); と仮定しています。Response.Write の前に rssData から削除します。ありがとう
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";
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(rssData.ToString());
XmlNode node = xmlDocument.SelectSingleNode(@"xhtml:div/xhtml:h3/xhtml[a = 'Archived Planes']");
if (node != null)
{
node.ParentNode.RemoveChild(node);
}
Response.Write(rssData);
以下の出力を含むように編集
This is the what the response.write from rssData is pumping out:
<?xml version="1.0" ?>
<rss xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
<channel>
<title>Plane feed</title>
<link>http://www.domain.rss1.aspx</link>
<description></description>
<item>
<title>New Planes</title>
<link>http://www.domainx1.aspx</link>
<description>
This is the description
</description>
<author>Andrew</author>
<pubDate>Thu, 16 Aug 2012 15:55:53 GMT</pubDate>
</item>
<item>
<title>Archived Planes</title>
<link>http://www.domain23.aspx</link>
<description>
Description of Archived Planes
</description>
<author>Jan</author>
<pubDate>Wed, 15 Aug 2012 10:34:23 GMT</pubDate>
</item>
</channel>
</rss>