/// <summary>
 /// Initialisiert eine neue Instanz der RSSFeed Klasse.
 /// Allen Eigenschaften wird ein Standartwert zugewiesen.
 /// </summary>
 public RSSFeed()
 {
     Description      = "";
     Image            = new RSSFeedImage();
     ImageDescription = "";
     Categories       = new List <RSSFeedCategory>();
     Docs             = "";
     Updated          = DateTime.MinValue;
     SkipDays         = new List <string>();
     SkipHours        = new List <byte>();
     TimeToLive       = int.MinValue;
     WebMaster        = "";
     TextInput        = new RSSFeedTextInput();
     ArticleUrl       = "";
     Title            = "";
     Generator        = "";
     Version          = "2.0";
     Author           = "";
 }
        /// <summary>
        /// Lädt die Daten aus dem XDocument (im RSS Format) in die Eigenschaften dieser Instanz.
        /// </summary>
        /// <param name="doc">Das zu ladende RSS Dokument.</param>
        private void SetDataFromDocument(XDocument doc)
        {
            XElement el = doc.Descendants("rss").Count() == 1
                    ? doc.Descendants("rss").Descendants("channel").Count() == 1
                        ? doc.Descendants("rss").Descendants("channel").Single()
                        : null
                    : null;

            if (el == null)
            {
                throw new InvalidCastException("Invalid RSS file");
            }

            //version="x.y"
            Version = doc.Descendants("rss").Attributes("version").Count() == 1 ? doc.Descendants("rss").Attributes("version").Single().Value : "2.0";

            //<category>...</categorie>
            Categories = (from c in el.Elements("category")
                          select new RSSFeedCategory()
            {
                CategoryName = c.Value,
                Domain = c.Attributes("domain").Count() == 1 ? c.Attributes("domain").Single().Value : "",
            }).ToList();
            //<skypedays>...</skipdays>
            SkipDays = (from c in el.Elements("skipDays").Elements("day")
                        select c.Value).ToList();
            //<skypehours>...</skypehours>
            SkipHours = (from c in el.Elements("skipHours").Elements("hour")
                         select byte.Parse(c.Value)).ToList();
            //<link>test.htm</link>
            if (el.Elements("link").Count() != 1)
            {
                throw new InvalidCastException("Invalid RSS file");
            }
            ArticleUrl = el.Elements("link").Count() == 1 ? el.Elements("link").Single().Value : "";
            //<docs>rss.htm</docs>
            Docs = el.Elements("docs").Count() == 1 ? el.Elements("docs").Single().Value : "";
            //<webMaster>rss.htm</webMaster>
            WebMaster = el.Elements("webMaster").Count() == 1 ? el.Elements("webMaster").Single().Value : "";
            //<title>Title</title>
            if (el.Elements("title").Count() != 1)
            {
                throw new InvalidCastException("Invalid RSS file");
            }
            Title = el.Elements("title").Count() == 1 ? el.Elements("title").Single().Value : "";
            //<description>Kurze Beschreibung</description>
            Description = el.Elements("description").Count() == 1 ? el.Elements("description").Single().Value : "";
            //<copyright>Copright</copyright>
            Copyrights = el.Elements("copyright").Count() == 1 ? el.Elements("copyright").Single().Value : "";
            //<pubDate>Sat, 20 Oct 2012 11:43:20 GMT</pubDate>
            Published = el.Elements("pubDate").Count() == 1 ? DateTime.Parse(el.Elements("pubDate").Single().Value) : DateTime.MinValue;
            //<ttl>60</ttl>
            TimeToLive = el.Elements("ttl").Count() == 1 ? int.Parse(el.Elements("ttl").Single().Value) : int.MinValue;
            //<pubDate>Sat, 20 Oct 2012 11:43:20 GMT</pubDate>
            Updated = el.Elements("lastBuildDate").Count() == 1 ? DateTime.Parse(el.Elements("lastBuildDate").Single().Value) : DateTime.MinValue;
            //<generator>Koopakiller.NewsFeed Classes</generator>
            Generator = el.Elements("generator").Count() == 1 ? el.Elements("generator").Single().Value : "";
            //<managingEditor>Autor</managingEditor>
            Author = el.Elements("managingEditor").Count() == 1 ? el.Elements("managingEditor").Single().Value : "";
            //<image>...</image>
            if (el.Elements("image").Count() == 1)
            {
                //<url>http://koopakiller.ko.ohost.de/images/bg.png</url>
                Image.Url = el.Elements("image").Descendants("url").Count() == 1 ? el.Elements("image").Descendants("url").Single().Value : "";
                //<title>Title</title>
                Image.Title = el.Elements("image").Descendants("title").Count() == 1 ? el.Elements("image").Descendants("title").Single().Value : "";
                //<link>test.htm</link>
                Image.Link = el.Elements("image").Descendants("link").Count() == 1 ? el.Elements("image").Descendants("link").Single().Value : "";
                //<height>90</height>
                Image.Height = el.Elements("image").Descendants("height").Count() == 1 ? int.Parse(el.Elements("image").Descendants("height").Single().Value) : 31;
                //<width>90</width>
                Image.Width = el.Elements("image").Descendants("width").Count() == 1 ? int.Parse(el.Elements("image").Descendants("width").Single().Value) : 88;
                //<description>Beschreibung...</description>
                ImageDescription = el.Elements("image").Descendants("description").Count() == 1 ? el.Elements("image").Descendants("description").Single().Value : "";
            }
            //<textinput>...</textinput>
            if (el.Elements("textinput").Count() == 1)
            {
                TextInput = new RSSFeedTextInput();
                //<description>Beschreibung</description>
                TextInput.Description = el.Elements("textinput").Descendants("description").Count() == 1 ? el.Elements("textinput").Descendants("description").Single().Value : "";
                //<name>...</name>
                TextInput.Name = el.Elements("textinput").Descendants("name").Count() == 1 ? el.Elements("textinput").Descendants("name").Single().Value : "";
                //<link>...</link>
                TextInput.Link = el.Elements("textinput").Descendants("link").Count() == 1 ? el.Elements("textinput").Descendants("link").Single().Value : "";
                //<title>test.htm</title>
                TextInput.Title = el.Elements("textinput").Descendants("title").Count() == 1 ? el.Elements("textinput").Descendants("title").Single().Value : "";
            }
            //<language>de-de</language>
            Language = el.Elements("language").Count() == 1 ? CultureInfo.CreateSpecificCulture(el.Elements("language").Single().Value) : CultureInfo.InvariantCulture;
            //<item>...</item>
            Articles = (from x in el.Elements("item")
                        select(FeedArticleBase) new RSSFeedArticle()
            {
                Categories = (from c in x.Elements("catagory")
                              select new RSSFeedCategory()
                {
                    CategoryName = c.Value,
                    Domain = c.Attributes("domain").Count() == 1 ? c.Attributes("domain").Single().Value : "",
                }).ToList(),
                ArticleUrl = x.Elements("link").Count() == 1 ? x.Elements("link").Single().Value : "",
                Author = x.Elements("author").Count() == 1 ? x.Elements("author").Single().Value : "",
                Content = x.Elements("description").Count() == 1 ? x.Elements("description").Single().Value : "",
                Title = x.Elements("title").Count() == 1 ? x.Elements("title").Single().Value : "",
                Guid = new RSSFeedArticleGuid()
                {
                    Guid = x.Elements("guid").Count() == 1 ? x.Elements("guid").Single().Value : "",
                    IsPermaLink = x.Elements("link").Count() == 1 ? x.Elements("link").Attributes("isPermaLink").Count() == 1 ? bool.Parse(x.Elements("link").Attributes("isPermaLink").Single().Value) : false : false,
                },
                Comments = x.Elements("comments").Count() == 1 ? x.Elements("comments").Single().Value : "",
                Published = x.Elements("pubDate").Count() == 1 ? DateTime.Parse(x.Elements("pubDate").Single().Value) : DateTime.MinValue,
                Enclosure = new RSSFeedArticleEnclosure()
                {
                    Url = x.Elements("enclosure").Count() == 1 ? x.Elements("enclosure").Attributes("url").Count() == 1 ? x.Elements("enclosure").Attributes("url").Single().Value : "" : "",
                    Type = x.Elements("enclosure").Count() == 1 ? x.Elements("enclosure").Attributes("type").Count() == 1 ? x.Elements("enclosure").Attributes("type").Single().Value : "" : "",
                    Length = x.Elements("enclosure").Count() == 1 ? x.Elements("enclosure").Attributes("length").Count() == 1 ? ulong.Parse(x.Elements("enclosure").Attributes("length").Single().Value) : ulong.MinValue : ulong.MinValue,
                },
                Source = new RSSFeedArticleSource()
                {
                    Source = x.Elements("source").Count() == 1 ? x.Elements("source").Single().Value : "",
                    Uri = x.Elements("source").Count() == 1 ? x.Elements("source").Attributes("url").Count() == 1 ? x.Elements("source").Attributes("url").Single().Value : "" : "",
                },
            }).ToList();
        }