c# - how can we do reverse iteration of last four items in the XmlNodeList -


at point displaying items in reverse order no limit. xmlnodelist can have many items. display last 4 items. how can find or display last 4 items in list? anyone?

xmlnodelist mytestlist = myrssdocument.selectnodes("test/holder/item");  string title = ""; string link = "";   (int = mytestlist.count - 1; >= 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 = ""; } 

you can replace following line:

for (int = mytestlist.count - 1; >= 0; i--) 

by this:

for (int = mytestlist.count - 1; >= (mytestlist.count - 4) ; i--) 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -