XML : How to create an MRSS element using C#?

Dabbling in creating an RSS feed using Syndication and I'm trying to replace an existing element:

  <image>http://test.website.com/abc</image>    

Into

  <media:thumbnail src="http://test.website.com/abc"></media:thumnail>    

Or

  <media:thumbnail src="http://test.website.com/abc" />    

At the moment this is how far I've gotten:

  XNamespace media = "http://search.yahoo.com/mrss/";  var thumbnail = new XElement(media + "thumbnail",      new XAttribute("src", !string.IsNullOrEmpty(item.Image) ? item.Image : string.Empty));    _syndicationItem.ElementExtensions.Add(thumbnail);    

This results in:

  <thumbnail src="/images/abc.jpg" xmlns="http://search.yahoo.com/mrss/" />    

I've made sure that the namespace have been declared.

Other things that I've tried:

  • Hard coded the string "media:thumbnail" but this threw an error as I'm not supposed to add : in an XML definition.

Used these for reference:

Is this possible to do or am I missing something?

No comments:

Post a Comment