private BaseFeedItem ParseAtom10SingleItem(XmlNode itemNode)
        {
            var titleNode         = itemNode.SelectSingleNode("atom:title", NsManager);
            var datePublishedNode = itemNode.SelectSingleNode("atom:updated", NsManager);
            var authorNode        = itemNode.SelectSingleNode("atom:author/name", NsManager);
            var idNode            = itemNode.SelectSingleNode("atom:id", NsManager);
            var contentNode       = itemNode.SelectSingleNode("atom:content", NsManager);
            var linkNode          = itemNode.SelectSingleNode("atom:link/@href", NsManager);

            BaseFeedItem item = new Atom10FeedItem
            {
                Title         = titleNode == null ? string.Empty : titleNode.InnerText,
                DatePublished = datePublishedNode == null ? DateTime.UtcNow : SafeGetDate(datePublishedNode.InnerText),
                Author        = authorNode == null ? string.Empty : authorNode.InnerText,
                Id            = idNode == null ? string.Empty : idNode.InnerText,
                Content       = contentNode == null ? string.Empty : contentNode.InnerText,
                Link          = linkNode == null ? string.Empty : linkNode.InnerText
            };

            var categoryNodes = itemNode.SelectNodes("atom:category/atom:term", NsManager);

            if (categoryNodes != null)
            {
                foreach (XmlNode categoryNode in categoryNodes)
                {
                    item.Categories.Add(categoryNode.InnerText);
                }
            }

            return(item);
        }
Example #2
0
        protected virtual BaseFeedItem ParseAtom10SingleItem(XElement itemNode)
        {
            var titleNode         = itemNode.Element(Atom10Namespace + "title");
            var datePublishedNode = itemNode.Element(Atom10Namespace + "updated");
            var authorNode        = itemNode.Element(Atom10Namespace + "author") == null ? null : itemNode.Element(Atom10Namespace + "author").Element(Atom10Namespace + "name");
            var idNode            = itemNode.Element(Atom10Namespace + "id");
            var contentNode       = itemNode.Element(Atom10Namespace + "content");
            var linkNode          = itemNode.Element(Atom10Namespace + "link") == null ? null : itemNode.Element(Atom10Namespace + "link").Attribute("href");

            //create the new item
            Atom10FeedItem item = CreateAtom10FeedItem();

            item.Title         = titleNode == null ? string.Empty : titleNode.Value;
            item.DatePublished = datePublishedNode == null ? DateTime.UtcNow : SafeGetDate(datePublishedNode.Value);
            item.Author        = authorNode == null ? string.Empty : authorNode.Value;
            item.Id            = idNode == null ? string.Empty : idNode.Value;
            item.Content       = contentNode == null ? string.Empty : contentNode.Value;
            item.Link          = linkNode == null ? string.Empty : linkNode.Value;

            var categoryNode = itemNode.Element(Atom10Namespace + "category");

            if (categoryNode != null)
            {
                var categoryNodes = categoryNode.Elements(Atom10Namespace + "term");
                foreach (var termNode in categoryNodes)
                {
                    item.Categories.Add(termNode.Value);
                }
            }

            return(item);
        }
        private BaseFeedItem ParseAtom10SingleItem(XmlNode itemNode)
        {
            var titleNode = itemNode["atom:title"];
            var datePublishedNode = itemNode["atom:updated"];
            var authorNode = itemNode["atom:author/name"];
            var idNode = itemNode["atom:id"];
            var contentNode = itemNode["atom:content"];
            var linkNode = itemNode["atom:link/@href"];

            BaseFeedItem item = new Atom10FeedItem
            {
                Title = titleNode == null ? string.Empty : titleNode.InnerText,
                DatePublished = datePublishedNode == null ? DateTime.UtcNow : SafeGetDate(datePublishedNode.InnerText),
                Author = authorNode == null ? string.Empty : authorNode.InnerText,
                Id = idNode == null ? string.Empty : idNode.InnerText,
                Content = contentNode == null ? string.Empty : contentNode.InnerText,
                Link = linkNode == null ? string.Empty : linkNode.InnerText
            };

            var categoryNodes = itemNode["atom:category/atom:term"];
            if (categoryNodes != null)
            {
                foreach (XmlNode categoryNode in categoryNodes)
                {
                    item.Categories.Add(categoryNode.InnerText);
                }
            }

            return item;
        }