我有以下代码
foreach (var rssItem in rss.Channel.Items)
{
// ...
}
Run Code Online (Sandbox Code Playgroud)
但是只想要6个项目而不是所有项目,我怎么能用C#做呢?
我的html存储在我的c#.net 2.0代码中的字符串变量中.以下是一个例子:
<div class="track">
<img alt="" src="http://hits.guardian.co.uk/b/ss/guardiangu-feeds/1/H.20.3/30561?ns=guardian&pageName=Hundreds+feared+dead+in+Haiti+quake%3AArticle%3A1336252&ch=World+news&c3=GU.co.uk&c4=Haiti+%28News%29%2CDominican+Republic+%28News%29%2CCuba+%28News%29%2CBahamas+%28News%29%2CNatural+disasters+and+extreme+weather+%28News%29%2CEnvironment%2CWorld+news&c6=Rory+Carroll%2CHaroon+Siddique&c7=10-Jan-13&c8=1336252&c9=Article&c10=News&c11=World+news&c13=&c25=&c30=content&h2=GU%2FWorld+news%2FHaiti" width="1" height="1" />
</div>
<p class="standfirst">
• Tens of thousands lose homes in 7.0 magnitude quake<br />
• UN headquarters, schools and hospitals collapse
</p>
<p>
René Préval, the president of Haiti, has described the devastation after last night's earthquake as "unimaginable" as governments and aid agencies around the world rushed into action.
</p>
<p>
Préval described how he had been forced to step over dead bodies and heard the cries of those …Run Code Online (Sandbox Code Playgroud)