当最新的书籍添加到 xml 的底部时,您可以执行类似的操作(我使用前 2 名进行测试,而不是前 5 名)
XmlDocument xml = new XmlDocument();
string xmlString = "<Books><book><author>xx</author><title>abc</title></book><book><author>yy</author><title>efg</title></book>" +
"<book><author>xx2</author><title>abc2</title></book><book><author>yy2</author><title>efg2</title></book></Books>";
//load xml from string or file
xml.LoadXml(xmlString);
int count = xml.SelectNodes("/Books/book").Count - 2;
XmlNodeList xnList = xml.SelectNodes(string.Format("/Books/book[position() > {0}]", count));
foreach (XmlNode xn in xnList)
{
//do something with node
Response.Write(xn.InnerText);
}