Beispiel #1
0
        private void readItem(XmlReader subReader)
        {
            subReader.MoveToContent();
            FeedItem feedItem = new FeedItem();

            while (subReader.Read())
            {
                if (subReader.NodeType == XmlNodeType.Element)
                {
                    switch (subReader.Name)
                    {
                        case "title":
                            subReader.MoveToContent();
                            feedItem.Title = subReader.ReadString();
                            break;
                        case "link":
                            subReader.MoveToContent();
                            FeedUri uri = new FeedUri(subReader.ReadString());
                            feedItem.WebUris.Add(uri);
                            break;
                        case "description":
                            subReader.MoveToContent();
                            try
                            {
                                // One feed had a hex character that couldnt be read with XmlReader.
                                // TODO: Build a function TryReadString(XmlReader) for all string elements?...
                                feedItem.Content = subReader.ReadString();
                            }
                            catch { }
                            break;
                        default:
                            if (readModules && subReader.Prefix != String.Empty)
                                readModuleItem(subReader, feedItem);
                            break;
                    }
                }
            }

            Feed.Items.Add(feedItem);
        }
Beispiel #2
0
        private void readItem(XmlReader subReader)
        {
            subReader.MoveToContent();
            m_CurrentFeedItem = new FeedItem();

            while (subReader.Read())
            {
                if (subReader.NodeType == XmlNodeType.Element)
                {
                      m_CurrentNode = subReader.Name;
                      switch (m_CurrentNode)
                        {
                            case "title":
                                subReader.MoveToContent();
                                m_CurrentFeedItem.Title = subReader.ReadString();
                                break;
                            case "description":
                                subReader.MoveToContent();
                                try
                                {
                                    // One feed had a hex character / & that couldnt be read with XmlReader.
                                  m_CurrentFeedItem.Content = subReader.ReadString();
                                }
                                catch(Exception ex)
                                {
                                  System.Diagnostics.Debug.WriteLine("Error reading the description of a feed item.  Ignored usually: "+ex.Message);
                                }
                                break;
                            case "link":
                                subReader.MoveToContent();
                                FeedUri uri = new FeedUri(subReader.ReadString());
                                m_CurrentFeedItem.WebUris.Add(uri);
                                break;
                            case "author":
                                subReader.MoveToContent();
                                m_CurrentFeedItem.Authors.Add(readPerson(subReader.ReadString()));
                                break;
                            case "category":
                                Category category = new Category();
                                while (subReader.MoveToNextAttribute())
                                {
                                    if (subReader.Name == "domain")
                                        category.Scheme = subReader.Value;
                                }
                                subReader.MoveToContent();
                                category.Label = category.Term = subReader.ReadString();
                                m_CurrentFeedItem.Categories.Add(category);
                                break;
                            case "comments":
                                subReader.MoveToContent();
                                m_CurrentFeedItem.CommentsUri = subReader.ReadString();
                                break;
                            case "enclosure":
                                Enclosure enclosure = new Enclosure();
                                while (subReader.MoveToNextAttribute())
                                {
                                    switch (subReader.Name)
                                    {
                                        case "url": enclosure.Uri = subReader.Value; break;
                                        case "length":
                                            int length = 0;
                                            if (Int32.TryParse(subReader.Value, out length))
                                                enclosure.Length = length;
                                            break;
                                        case "type": enclosure.Type = subReader.Value; break;
                                    }
                                }
                                m_CurrentFeedItem.Enclosures.Add(enclosure);
                                break;
                            case "guid":
                                FeedGuid guid = new FeedGuid();
                                if (subReader.MoveToFirstAttribute())
                                {
                                    if (subReader.Name == "isPermaLink" && subReader.Value == "false")
                                        guid.PermaLink = false;
                                }
                                subReader.MoveToContent();
                                guid.Id = subReader.ReadString();
                                m_CurrentFeedItem.Guid = guid;
                                break;
                            case "pubDate":
                                subReader.MoveToContent();
                                m_CurrentFeedItem.Published = DTHelper.ParseDateTime(subReader.ReadString());
                                break;
                            case "source":
                                Source source = new Source();
                                if (subReader.MoveToFirstAttribute())
                                {
                                    if (subReader.Name == "url")
                                        source.Uri = subReader.Value;
                                }
                                subReader.MoveToContent();
                                source.Title = subReader.ReadString();
                                m_CurrentFeedItem.Source = source;
                                break;
                            default:
                                if (readModules && subReader.Prefix != String.Empty)
                                  readModuleItem(subReader, m_CurrentFeedItem);
                                break;
                        }

                    }
            }

            Feed.Items.Add(m_CurrentFeedItem);
        }
Beispiel #3
0
 public Feed(Feed feed)
 {
     this.authors = feed.authors;
     this.categories = feed.categories;
     this.cloud = feed.cloud;
     this.contributors = feed.contributors;
     this.copyright = feed.copyright;
     this.description = feed.description;
     this.generator = feed.generator;
     this.icon = feed.icon;
     this.id = feed.id;
     this.image = feed.image;
     this.items = feed.items;
     this.language = feed.language;
     this.modules = feed.modules;
     this.published = feed.published;
     this.rssDocumentation = feed.rssDocumentation;
     this.skipDays = feed.skipDays;
     this.skipHours = feed.skipHours;
     this.title = feed.title;
     this.ttl = feed.ttl;
     this.updated = feed.updated;
     this.version = feed.version;
     this.webMaster = feed.webMaster;
     this.webUri = feed.webUri;
     this.xmlUri = feed.xmlUri;
 }