Would have to see your source xml feed to be sure, and perhaps your error but...
... one thing to be aware of is that media:content is the content item from the media namespace declared at top of your rssfeed, and so if memory serves me correct you have to declare this same namespace in order to read the value...
You should then be able to select the media:content node like so:
@{
var mediaContent = node.SelectSingleNode("media:content",xnm);
var urlAttribute = mediaContent.Attributes["url"];
var url = urlAttribute !=null ? urlAttribute.Value : "";
}
but it is ages since I've done anything like this, because .net now has a SyndicationFeed class designed to read in RSS Feeds, which is normally the approach I use, although you still need to think about the namespaces
Anyway hopefully my vague recollection of namespaces being the problem gets you on the right google path to sorting this out! even if my suggested lines of code aren't exactly perfect!
Syntax Question about importing an rss feed
Hey guys,
Love Umbraco, but am not very well versed in all things cshtml.
I'm trying to do something really simple, import and render an rss feed. Here's what I have so far that works well
The one thing that I cannot figure out is rendering an image url from a media:content tag in the rss feed.
To give an idea of what i'm TRYING to do, here's a rough iteration of what I'm been spinning my tires on:
Am I way off here?
Hi JJ
Would have to see your source xml feed to be sure, and perhaps your error but...
... one thing to be aware of is that media:content is the content item from the media namespace declared at top of your rssfeed, and so if memory serves me correct you have to declare this same namespace in order to read the value...
https://www.wired.com/2010/02/usemediarss/
so my guess is you need to add this namespace after you load your document: eg:
Then according to this:
https://msdn.microsoft.com/en-us/library/h0hw012b(v=vs.110).aspx
You should then be able to select the media:content node like so:
but it is ages since I've done anything like this, because .net now has a SyndicationFeed class designed to read in RSS Feeds, which is normally the approach I use, although you still need to think about the namespaces
https://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed(v=vs.110).aspx
I've built a property editor for Umbraco, where it uses this approach to read an RSS feed Url entered into the backoffice... there is a blogpost here about it: http://tooorangey.co.uk/posts/feed-me-with-your-rss/ the code is on github https://github.com/marcemarc/tooorangey.RssFeedUrl
Anyway hopefully my vague recollection of namespaces being the problem gets you on the right google path to sorting this out! even if my suggested lines of code aren't exactly perfect!
regards
Marc
is working on a reply...