【发布时间】:2017-04-07 10:24:55
【问题描述】:
此时它正在以相反的顺序显示项目,没有限制。 XmlNodeList 可以有很多项。我只想显示最后四个项目。如何查找或显示列表中的最后四个项目?任何人?
XmlNodeList MyTestList = MyRssDocument.SelectNodes("test/holder/item");
string Title = "";
string Link = "";
for (int i = MyTestList.Count - 1; i >= 0; i--)
{
XmlNode MyTestDetail;
MyTestDetail = MyTestList.Item(i).SelectSingleNode("title");
if (MyTestDetail != null)
Title = MyTestDetail.InnerText;
else
Title = "";
MyTestDetail = MyTestList.Item(i).SelectSingleNode("link");
if (MyTestDetail != null)
Link = MyTestDetail.InnerText;
else
Link = "";
}
【问题讨论】:
标签: c# asp.net .net loops c#-4.0