Last active
December 13, 2015 21:48
-
-
Save jokecamp/4979703 to your computer and use it in GitHub Desktop.
RSS Example Output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Net; | |
using ServiceStack.Text; | |
using System.Runtime.Serialization; | |
using System.Xml; | |
[assembly: ContractNamespace("", ClrNamespace = "ServiceStackTester")] | |
namespace ServiceStackTester | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string str = "http://static.cricinfo.com/rss/livescores.xml"; | |
WebClient w = new WebClient(); | |
string xml = w.DownloadString(str); | |
//To change rss Element to Response as in Exception | |
xml = xml.Replace("<rss version=\"2.0\">", "<Response><rss version=\"2.0\">"); | |
//For closing tag | |
xml = xml.Replace("</rss>", "</rss></Response>"); | |
var rss = xml.FromXml<Response>(); | |
Console.WriteLine(rss.rss.channel.title); | |
Console.Read(); | |
} | |
} | |
public class Response | |
{ | |
public rss rss { get; set; } | |
} | |
public class rss | |
{ | |
public string version { get; set; } | |
public ChannelClass channel { get; set; } | |
} | |
public class ChannelClass | |
{ | |
public string title { get; set; } | |
public string ttl { get; set; } | |
public string description { get; set; } | |
public string link { get; set; } | |
public string copyright { get; set; } | |
public string language { get; set; } | |
public string pubDate { get; set; } | |
public List<ItemClass> item { get; set; } | |
} | |
public class ItemClass | |
{ | |
public string title { get; set; } | |
public string link { get; set; } | |
public string description { get; set; } | |
public string guid { get; set; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Response xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> | |
<rss> | |
<Version>2</Version> | |
<channel> | |
<copyright i:nil="true" /> | |
<description>description</description> | |
<item> | |
<ItemClass> | |
<description i:nil="true" /> | |
<guid i:nil="true" /> | |
<link i:nil="true" /> | |
<title>title</title> | |
</ItemClass> | |
<ItemClass> | |
<description i:nil="true" /> | |
<guid i:nil="true" /> | |
<link i:nil="true" /> | |
<title>title</title> | |
</ItemClass> | |
</item> | |
<language i:nil="true" /> | |
<link i:nil="true" /> | |
<pubDate i:nil="true" /> | |
<title>title</title> | |
<ttl i:nil="true" /> | |
</channel> | |
</rss> | |
</Response> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment