本文整理汇总了C#中System.ServiceModel.Syndication.SyndicationFeed类的典型用法代码示例。如果您正苦于以下问题:C# SyndicationFeed类的具体用法?C# SyndicationFeed怎么用?C# SyndicationFeed使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SyndicationFeed类属于System.ServiceModel.Syndication命名空间,在下文中一共展示了SyndicationFeed类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SyndicationFeed
SyndicationFeed feed = new SyndicationFeed("Feed Title", "Feed Description", new Uri("http://Feed/Alternate/Link"), "FeedID", DateTime.Now);
// Add a custom attribute.
XmlQualifiedName xqName = new XmlQualifiedName("CustomAttribute");
feed.AttributeExtensions.Add(xqName, "Value");
SyndicationPerson sp = new SyndicationPerson("jesper@contoso.com", "Jesper Aaberg", "http://Jesper/Aaberg");
feed.Authors.Add(sp);
SyndicationCategory category = new SyndicationCategory("FeedCategory", "CategoryScheme", "CategoryLabel");
feed.Categories.Add(category);
feed.Contributors.Add(new SyndicationPerson("lene@contoso.com", "Lene Aaling", "http://lene/aaling"));
feed.Copyright = new TextSyndicationContent("Copyright 2007");
feed.Description = new TextSyndicationContent("This is a sample feed");
// Add a custom element.
XmlDocument doc = new XmlDocument();
XmlElement feedElement = doc.CreateElement("CustomElement");
feedElement.InnerText = "Some text";
feed.ElementExtensions.Add(feedElement);
feed.Generator = "Sample Code";
feed.Id = "FeedID";
feed.ImageUrl = new Uri("http://server/image.jpg");
TextSyndicationContent textContent = new TextSyndicationContent("Some text content");
SyndicationItem item = new SyndicationItem("Item Title", textContent, new Uri("http://server/items"), "ItemID", DateTime.Now);
List<SyndicationItem> items = new List<SyndicationItem>();
items.Add(item);
feed.Items = items;
feed.Language = "en-us";
feed.LastUpdatedTime = DateTime.Now;
SyndicationLink link = new SyndicationLink(new Uri("http://server/link"), "alternate", "Link Title", "text/html", 1000);
feed.Links.Add(link);
XmlWriter atomWriter = XmlWriter.Create("atom.xml");
Atom10FeedFormatter atomFormatter = new Atom10FeedFormatter(feed);
atomFormatter.WriteTo(atomWriter);
atomWriter.Close();
XmlWriter rssWriter = XmlWriter.Create("rss.xml");
Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(feed);
rssFormatter.WriteTo(rssWriter);
rssWriter.Close();