[英]Get the first 5 nodes from XmlDocument
I need help getting the first five nodes from feedSource 我需要帮助来从feedSource获取前五个节点
XmlDocument feedSource = FeedSource;
if (feedSource != null)
{
Rss.DataSource = feedSource.SelectNodes("//item")
Rss.DataBind();
}
I've seen in other examples that i should be able to use 我在其他示例中看到我应该可以使用
Rss.DataSource = feedSource.SelectNodes("//item")[position() <= 5]
Rss.DataBind();
but that doesn't work. 但这不起作用。 Any help would be appreciated. 任何帮助,将不胜感激。
Try this 尝试这个
Rss.DataSource = feedSource.SelectNodes("//item[position() <= 5]");
That []
part belongs to the XPath query, not to the C# part. 该[]
部分属于XPath查询,而不属于C#部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.