我目前正在使用代码
string[] toSearch = { "title", "link", "description" };
string url = "http://www.ebay.co.uk/sch/i.html?_sacat=0&_from=R40&_nkw=" + itemToSearch.Replace(" ", "+") + "&_sop=15&_rss=1";
WebRequest request = WebRequest.Create(url);
WebResponse responce = request.GetResponse();
Stream rssStream = responce.GetResponseStream();
XmlDocument rssDocument = new XmlDocument();
rssDocument.Load(rssStream);
XmlNodeList rssItems = rssDocument.SelectNodes("channel/item");
int xMax = toSearch.Length;
int yMax = rssItems.Count;
String[,] tempRssData = new String[yMax + 1, xMax];
for (int i = 0; i < rssItems.Count; ++i)
{
XmlNode rssNode = null;
for (int ii = 0; ii < toSearch.Length; ++ii)
{
rssNode = rssItems.Item(i).SelectSingleNode(toSearch[ii]);
if (rssNode != null)
{
tempRssData[i, ii] = rssNode.InnerText;
}
else
{
tempRssData[i, ii] = "";
}
}
}
但是 rssItems.Count = 0,有谁知道为什么。我正在使用的 rss 提要的示例是 http://www.ebay.co.uk/sch/i.html?_sacat=0&_from=R40&_nkw=raspberry+pi&_sop=15&_rss=1