how to add attributes to syndicationitem elementextension

646 Views Asked by At

I am trying to add the media:thumnail element to the atom feed using SyndicationFeed .net class.

my code looks like the below

            item.ElementExtensions.Add(new XElement("thumbnail",
                                            new XAttribute("xmlns", "http://search.yahoo.com/mrss/"),
                                            new XAttribute("url", "http://test.com/test.jpg/"),
                                            new XAttribute("width", 200),
                                            new XAttribute("height", 200)
                                        ).CreateReader()
                                    );

which outputs as

<thumbnail url="http://test.com/test.jpg/" width="200" height="200"          xmlns="http://search.yahoo.com/mrss/">
        </thumbnail>

which is still seems to be valid atom feed. But as per client requirement, I want the format to be
"<media:thumbnail>". Could anyone please help me on this?

I even tried like this

item.ElementExtensions.Add("thumbnail", "http://search.yahoo.com/mrss/", 10);

which outputs as

 <media:thumbnail>10</media:thumbnail>

but how do I add attributes instead of value?

1

There are 1 best solutions below

0
On

finally I resolved the xml namespace issue after looking at this...

[SyndicationFeed change namespace prefix from a10 to atom

for some odd reason I never found that question before I post mine in stackoverflow :(