This project has moved. For the latest updates, please go here.

How to serialize a custom RSSDocument object?

Topics: Developer Forum, User Forum
Jul 1, 2007 at 4:56 AM
I am trying to serialize a custom RSSDocument object that was created using the RssDl tool. This custom RSSDocument object suports Yahoo Media extensions. i.e. <media:credit>James</media:credit>. However when I serialize this object, the RSS feed outputs the content in the following format: <credit xmlns="http://search.yahoo.com/mrss/">James</credit>.

My question is how do I alter the custom RSSDocument object to serialize the object with the following format: <media:credit>James</media:credit>.

Thanks in advance,

Jason
Jul 18, 2007 at 1:31 AM
I'm after the same thing but for georss extensions. Any ideas on a workaround or fix for the problem?
Aug 16, 2007 at 10:45 PM
I'm seeking the same thing as luke. Need the resulting feed to keep the namespace, ie: for GeoRSS... <geo:lat>37.4</geo:lat> instead of <lat>37.4</lat>
Aug 22, 2007 at 6:54 PM
I would love to find a solution to this as well for GeoRSS.
Jan 11, 2008 at 12:43 AM
I'd also love a soultion to the GeoRSS issue!
Jan 12, 2008 at 11:11 AM
For thoose that are interested I have made a work around for the GeoRSS issue...

Below is the .rss file content that goes in the app_code folder...

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:georss="http://www.georss.org/georss">
<channel>
<title></title>
<link></link>
<description></description>
<item>
<title></title>
<link></link>
<description></description>
<ppoint>43.127697 -77.573776</ppoint>
<guid></guid>
<geo:Point>
<geo:lat></geo:lat>
<geo:long></geo:long>
</geo:Point>
</item>
<item>
<title></title>
<link></link>
<description>HTMl Encoded Description</description>
<ppoint>43.127697 -77.573776</ppoint>
<geo:Point>
<geo:lat>lat</geo:lat>
<geo:long>long</geo:long>
</geo:Point>
</item>
</channel>
</rss>

Now after you have done the normal building of your data in the ashx place this at the bottom of the fucntion.

Context.Response.Clear()
Dim str As String = Rss.ToDataSet.GetXml()
Context.Response.ContentType = "application/rss+xml"
str = str.Replace(" xmlns=""http://www.w3.org/2003/01/geo/wgs84_pos#""", "")

str = str.Replace("BeAQuoteHere", """)
str = str.Replace("Point>", "geo:Point>")
str = str.Replace("ppoint>", "georss:point>")
str = str.Replace("long>", "geo:long>")
str = str.Replace("lat>", "geo:lat>")
str = str.Replace("rss version=""2.0""", "rss version=""2.0"" " & vbCrLf & "xmlns:geo=""http://www.w3.org/2003/01/geo/wgs84_pos#"" " & vbCrLf & " xmlns:georss=""http://www.georss.org/georss""")
Context.Response.Write("<?xml version=""1.0"" encoding=""utf-8""?>" & vbCrLf)
Context.Response.Write(str)
Context.Response.End()

I know this isn't a pretty work around, put I just hacked it together in 20 mins and it works.
Mar 10, 2008 at 1:04 AM
Just put this in your custom RSSDocument object, it will change <point xmlns="http://www.georss.org/georss">10 10</point> to <georss:point>10 10</point>. It has noting to do with the RSSToolkit, it is just how XmlSerializer works.

[XmlNamespaceDeclarations]
public XmlSerializerNamespaces Namespaces
{