Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm new in Razor... so I'm puzzleing a lot with even small features.
I have succesfully made a macro that renders a rss feed (thanks to Our). Now I need it to only render the first item. How do I do that?
Well, I got it:
@{XmlTextReader dibertFeed = new XmlTextReader("http://feed.dilbert.com/dilbert/daily_strip");XmlDocument doc = new XmlDocument();doc.Load(dibertFeed);XmlNodeList rssItems = doc.SelectNodes("//item");}
@{ List<dynamic> strips = new List<dynamic>(); foreach (XmlNode node in rssItems) { var i = new { Title = Html.Raw(node["description"].InnerText), Url = node["link"].InnerText }; strips.Add(i); } foreach(var item in strips.Take(1)) { <div class="dilbert"><a href="@item.Url" target="_blank">@item.Title</a></div> }}
Thanks to Douglas Ludlow and Warren Buckley
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Only get first node in xml feed
I'm new in Razor... so I'm puzzleing a lot with even small features.
I have succesfully made a macro that renders a rss feed (thanks to Our). Now I need it to only render the first item. How do I do that?
Well, I got it:
Thanks to Douglas Ludlow and Warren Buckley
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.