I’m diving in to Orchard CMS and ASP.NET MVC, and could do with a little help. I am consuming an RSS feed that consists of HTML -a link around an image- that I want to keep, followed by some text that I don’t want.
Eg:
<a href="/pin/215609900880326101/"><img src="http://media-cache-ec3.pinterest.com/upload/65935582014430387_d5ueoRR6_b.jpg"></a>Nice graphic design & typography
I figure the best way to do this is use a regex to detect the required HTML. However I don’t have much experience of regex formatting, nor do I know how I should go about implementing the regex within my scenario. The code below is what I’m currently working with:
@using System.Xml.Linq
@{
var feed = Model.Feed as XElement;
}
<ul>
@foreach(var item in feed
.Element("channel")
.Elements("item")
.Take((int)Model.ItemsToDisplay)) {
<li>@T(item.Element("description").Value))</li>
}
</ul>
So, I essentially have two questions (with no1 being the most important):
- How should I implement a regex to lose the unwanted free text
- What would the regex be that I need to do this
I dealt with this using css to hide the text.