Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我需要一些从Wordpress导入RSS提要的帮助_C#_Asp.net - Fatal编程技术网

C# 我需要一些从Wordpress导入RSS提要的帮助

C# 我需要一些从Wordpress导入RSS提要的帮助,c#,asp.net,C#,Asp.net,我正在尝试从Wordpress RSS源导入最后5篇文章,并在我的网站上显示它们 我用的是这个,但它抓住了整个饲料 <asp:DataList ID="dataNews" runat="server" DataSourceID="xmlSource" > <ItemTemplate> <a href="<%# XPath("link") %>"><%# XPath("title") %></

我正在尝试从Wordpress RSS源导入最后5篇文章,并在我的网站上显示它们

我用的是这个,但它抓住了整个饲料

<asp:DataList ID="dataNews" runat="server" DataSourceID="xmlSource" >
        <ItemTemplate>
            <a href="<%# XPath("link") %>"><%# XPath("title") %></a>
        </ItemTemplate>
</asp:DataList>
<asp:XmlDataSource ID="xmlSource" runat="server" DataFile="http://myblog.com/feed" XPath="rss/channel/item" EnableCaching="true" />


如何实现这一点?

您可以使用XPath表达式来帮助您实现这一点,如本文所述:。以下几点应该行得通

<asp:XmlDataSource ID="xmlSource" runat="server" DataFile="http://myblog.com/feed" XPath="rss/channel/item[position()<6]" EnableCaching="true" />

这很有效。所以谢谢你!但如果我的博客订阅被关闭,它将错误地出现在我的整个头版。我应该把这些都写在代码中,还是有一些选项可以使用我的代码?