Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting custom rss feed item element with syndicationitem?

Tags:

c#

I have an RSS feed like so:

<item>
<title>
Ellen celebrates the 20th anniversary of coming out episode
</title>
<link>
http://www.dailymail.co.uk/video/tvshowbiz/video-1454179/Ellen-celebrates-20th-anniversary-coming-episode.html?ITO=1490&ns_mchannel=rss&ns_campaign=1490
</link>
<description>
Ellen celebrates 20th anniversary of coming out episode on her old sitcom 'Ellen'. Ellen said she cried during rehearsals but urged everyone to stay true to themselves and it will benefit you in the long term.
</description>
<enclosure url="http://i.dailymail.co.uk/i/pix/2017/04/27/00/3FA409EA00000578-0-image-m-21_1493249529333.jpg" type="image/jpeg" length="7972"/>
<pubDate>Thu, 27 Apr 2017 00:45:14 +0100</pubDate>
<guid>
http://www.dailymail.co.uk/video/tvshowbiz/video-1454179/Ellen-celebrates-20th-anniversary-coming-episode.html?ITO=1490&ns_mchannel=rss&ns_campaign=1490
</guid>
<media:description/>
<media:thumbnail url="http://i.dailymail.co.uk/i/pix/2017/04/27/00/3FA409EA00000578-0-image-m-21_1493249529333.jpg" width="154" height="115"/>
<media:credit scheme="urn:ebu">YouTube</media:credit>
<media:content url="http://video.dailymail.co.uk/video/mol/2017/04/26/4464646762446275941/1024x576_MP4_4464646762446275941.mp4" type="video/mp4" medium="video" duration="245" lang="en"/>
</item>

I am trying to get the url value of media:content, when I loop through the syndication items like so:

            foreach (SyndicationItem item in feed.Items)
            {

                foreach (SyndicationElementExtension extension in item.ElementExtensions)
                {
                    XElement ele = extension.GetObject<XElement>();
                    MessageBox.Show(ele.Value);
                }


            }

I get blank data, how can I get the url of the media content?

like image 495
4334738290 Avatar asked Apr 27 '17 00:04

4334738290


1 Answers

have you tried:

XElement ele = extension.GetObject<XElement>();
if (ele.Name.LocalName == "content")
{
   MessageBox.Show(ele.Attribute("url").Value);
}
like image 147
wal Avatar answered Nov 08 '22 23:11

wal