SyndicationFeed Classe
Definição
Representa um objeto de feed de nível superior, <feed> no Atom 1.0 e <rss> no RSS 2.0.Represents a top-level feed object, <feed> in Atom 1.0 and <rss> in RSS 2.0.
public ref class SyndicationFeed
public class SyndicationFeed
type SyndicationFeed = class
Public Class SyndicationFeed
- Herança
-
SyndicationFeed
Exemplos
O código a seguir mostra como criar uma SyndicationFeed instância e serializá-la para o Atom 1,0 e o RSS 2,0.The following code shows how to create a SyndicationFeed instance and serialize it to both Atom 1.0 and RSS 2.0.
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();
Dim feed As SyndicationFeed = New SyndicationFeed("Feed Title", "Feed Description", New Uri("http:'Feed/Alternate/Link"), "FeedID", DateTime.Now)
' Add a custom attribute.
Dim xqName As XmlQualifiedName = New XmlQualifiedName("CustomAttribute")
feed.AttributeExtensions.Add(xqName, "Value")
Dim sp As SyndicationPerson = New SyndicationPerson("jesper@contoso.com", "Jesper Aaberg", "http:'jesper/aaberg")
feed.Authors.Add(sp)
Dim category As SyndicationCategory = 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.
Dim doc As XmlDocument = New XmlDocument()
Dim feedElement As XmlElement = 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")
Dim textContent As TextSyndicationContent = New TextSyndicationContent("Some text content")
Dim item As SyndicationItem = New SyndicationItem("Item Title", textContent, New Uri("http:'server/items"), "ItemID", DateTime.Now)
Dim items As Collection(Of SyndicationItem) = New Collection(Of SyndicationItem)()
items.Add(item)
feed.Items = items
feed.Language = "en-us"
feed.LastUpdatedTime = DateTime.Now
Dim link As SyndicationLink = New SyndicationLink(New Uri("http:'server/link"), "alternate", "Link Title", "text/html", 1000)
feed.Links.Add(link)
Dim atomWriter As XmlWriter = XmlWriter.Create("atom.xml")
Dim atomFormatter As Atom10FeedFormatter = New Atom10FeedFormatter(feed)
atomFormatter.WriteTo(atomWriter)
atomWriter.Close()
Dim rssWriter As XmlWriter = XmlWriter.Create("rss.xml")
Dim rssFormatter As Rss20FeedFormatter = New Rss20FeedFormatter(feed)
rssFormatter.WriteTo(rssWriter)
rssWriter.Close()
O XML a seguir mostra como um SyndicationFeed é serializado para Atom 1,0.The following XML shows how a SyndicationFeed is serialized to Atom 1.0.
<feed xml:lang="en-us" CustomAttribute="Value" xmlns="http://www.w3.org/2005/Atom">
<title type="text">Feed Title</title>
<subtitle type="text">This is a sample feed</subtitle>
<id>FeedID</id>
<rights type="text">Copyright 2007</rights>
<updated>2007-04-13T17:29:38Z</updated>
<category term="FeedCategory" label="CategoryLabel" scheme="CategoryScheme" />
<logo>http://contoso/image.jpg</logo>
<author>
<name>Jesper Aaberg</name>
<uri>http://contoso/Aaberg</uri>
<email>Jesper.Asberg@contoso.com</email>
</author>
<contributor>
<name>Lene Aalling</name>
<uri>http://contoso/Aalling</uri>
<email>Lene.Aaling@contoso.com</email>
</contributor>
<generator>Sample Code</generator>
<link rel="alternate" type="text/html" title="Link Title" length="1000" href="http://contoso/link" />
<link customAttribute="value" rel="alternate" type="text/html" title="Link Title" length="1000" href="http://contoso/link" />
<CustomElement xmlns="">Some text</CustomElement>
<entry>
<id>ItemID</id>
<title type="text">Item Title</title>
<updated>2007-04-13T17:29:38Z</updated>
<link rel="alternate" href="http://contoso/items" />
<content type="text">Some text content</content>
</entry>
</feed>
O XML a seguir mostra como uma SyndicationFeed instância é serializada para RSS 2,0.The following XML shows how a SyndicationFeed instance is serialized to RSS 2.0.
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
<channel CustomAttribute="Value">
<title>Título do feed</title>
<link>http://feed/Alternate/Link</link>
<description>Este é um feed de exemplo</description>
<language>en-us</language>
<copyright>Copyright 2007</copyright>
<managingEditor>Jesper.Aaberg@contoso.com</managingEditor>
<lastBuildDate>Fri, 13 Apr 2007 17:29:38 Z</lastBuildDate>
<category domain="CategoryScheme">FeedCategory</category>
<a10:link rel="alternate" type="text/html" title="Link Title" length="1000" href="http://contoso/link" />
<generator>Sample Code</generator>
<a10:contributor>
<a10:name>Lene Aalling</a10:name>
<a10:uri>http://contoso/Aalling</a10:uri>
<a10:email>Lene.Aalling@contoso.com</a10:email>
</a10:contributor>
<a10:author>
<a10:name>Lene Aalling</a10:name>
<a10:uri>http://contoso/Aalling</a10:uri>
<a10:email>Lene.Aalling@contoso.com</a10:email>
</a10:author>
<image>
<url>http://contoso/image.jpg</url>
<title>Título do feed</title>
<link>http://feed/Alternate/Link</link>
</image>
<a10:id>FeedID</a10:id>
<a10:link customAttribute="value" rel="alternate" type="text/html" title="Link Title" length="1000" href="http://contoso/link" />
<CustomElement>Some text</CustomElement>
<item>
<guid isPermaLink="false">ItemID</guid>
<link>http://contoso/items</link>
<title>Título do item</title>
<description>Algum conteúdo de texto</description>
<a10:updated>2007-04-13T17:29:38Z</a10:updated>
</item>
</channel>
</rss>
Comentários
Quando serializado para Atom 1,0, uma SyndicationFeed instância é gravada em um <feed> elemento.When serialized to Atom 1.0, a SyndicationFeed instance is written to a <feed> element. A tabela a seguir mostra como cada propriedade definida na SyndicationFeed classe é serializada para Atom 1,0.The following table shows how each property defined in the SyndicationFeed class is serialized to Atom 1.0.
| Propriedade SyndicationFeedSyndicationFeed property | Formulário serializadoSerialized form |
|---|---|
AttributeExtensions |
Um atributo no <feed> elemento para cada atributo na coleção.An attribute in the <feed> element for each attribute in the collection. |
Authors |
Um <author> elemento para cada SyndicationPerson na coleção.An <author> element for each SyndicationPerson in the collection. |
Categories |
Um <category> elemento para cada SyndicationCategory na coleção.A <category> element for each SyndicationCategory in the collection. |
Contributors |
Um <contributor> elemento para cada SyndicationPerson na coleção.A <contributor> element for each SyndicationPerson in the collection. |
Copyright |
Um <rights> elemento.A <rights> element. |
Description |
Um <subtitle> elemento.A <subtitle> element. |
ElementExtensions |
Cada elemento na coleção é gravado dentro do <feed> elemento.Each element in the collection is written within the <feed> element. |
Generator |
Um <generator> elemento.A <generator> element. |
Id |
Um <id> elemento.An <id>element. |
ImageUri |
Um <logo> elemento.A <logo> element. |
Items |
Um <entry> elemento para cada SyndicationItem na coleção.An <entry> element for each SyndicationItem in the collection. |
Language |
Não serializado.Not serialized. |
LastUpdatedTime |
Um <updated> elemento.An <updated> element. |
Links |
Um <link> elemento para cada SyndicationLink na coleção.A <link> element for each SyndicationLink in the collection. |
Title |
Um <title> elemento.A <title> element. |
Quando serializado para RSS 2,0, uma SyndicationFeed instância é gravada em um <rss> elemento.When serialized to RSS 2.0, a SyndicationFeed instance is written to an <rss> element. A tabela a seguir mostra como cada propriedade definida na SyndicationFeed classe é serializada para RSS 2,0.The following table shows how each property defined in the SyndicationFeed class is serialized to RSS 2.0.
| Propriedade SyndicationFeedSyndicationFeed property | Formulário serializadoSerialized form |
|---|---|
AttributeExtensions |
Um atributo no <channel> elemento para cada atributo na coleção.An attribute in the <channel> element for each attribute in the collection. |
Authors |
Um <managingEditor> elemento se apenas um SyndicationPerson estiver na coleção; caso contrário, um <a10:author> elemento para cada SyndicationPerson na coleção.A <managingEditor> element if only one SyndicationPerson is in the collection; otherwise, an <a10:author> element for each SyndicationPerson in the collection. |
Categories |
Um <category> elemento para cada SyndicationCategory na coleção.A <category> element for each SyndicationCategory in the collection. |
Contributors |
Um <a10:contributor> elemento para cada SyndicationPerson na coleção.An <a10:contributor> element for each SyndicationPerson in the collection. |
Copyright |
Um <copyright> elemento.A <copyright> element. |
Description |
Um <description> elemento.A <description> element. |
ElementExtensions |
Cada elemento na coleção é gravado dentro do <channel> elemento.Each element in the collection is written within the <channel> element. |
Generator |
Um <generator> elemento.A <generator> element. |
Id |
Um <a10:id> elemento.An <a10:id> element. |
ImageUri |
Um <image> elemento.An <image> element. |
Items |
Um <item> elemento para cada SyndicationItem na coleção.An <item> element for each SyndicationItem in the collection. |
Language |
Um <language> elemento.A <language> element. |
LastUpdatedTime |
Um <lastBuildDate> elemento.A <lastBuildDate> element. |
Links |
Um <a10:link> elemento para cada SyndicationLink na coleção.An <a10:link> element for each SyndicationLink in the collection. |
Title |
Um <title> elemento.A <title> element. |
Construtores
| SyndicationFeed() |
Inicializa uma nova instância da classe SyndicationFeed.Initializes a new instance of the SyndicationFeed class. |
| SyndicationFeed(IEnumerable<SyndicationItem>) |
Inicializa uma nova instância da classe SyndicationFeed com a coleção especificada de objetos SyndicationItem.Initializes a new instance of the SyndicationFeed class with the specified collection of SyndicationItem objects. |
| SyndicationFeed(String, String, Uri) |
Inicializa uma nova instância da classe SyndicationFeed com o título, a descrição e o URI (Uniform Resource Identifier) especificados.Initializes a new instance of the SyndicationFeed class with the specified title, description, and Uniform Resource Identifier (URI). |
| SyndicationFeed(String, String, Uri, IEnumerable<SyndicationItem>) |
Inicializa uma nova instância da classe SyndicationFeed com o título, a descrição, o URI e a coleção de objetos SyndicationItem especificados.Initializes a new instance of the SyndicationFeed class with the specified title, description, URI, and collection of SyndicationItem objects. |
| SyndicationFeed(String, String, Uri, String, DateTimeOffset) |
Cria uma nova instância da classe SyndicationFeed.Creates a new instance of the SyndicationFeed class. |
| SyndicationFeed(String, String, Uri, String, DateTimeOffset, IEnumerable<SyndicationItem>) |
Cria uma nova instância da classe SyndicationFeed.Creates a new instance of the SyndicationFeed class. |
| SyndicationFeed(SyndicationFeed, Boolean) |
Cria uma nova instância da classe SyndicationFeed com o feed especificado.Creates a new instance of the SyndicationFeed class with the specified feed. |
Propriedades
| AttributeExtensions |
Obtém uma coleção de extensões de atributo.Gets a collection of attribute extensions. |
| Authors |
Obtém uma coleção de autores do feed.Gets a collection of authors of the feed. |
| BaseUri |
Obtém ou define o URI base da instância de SyndicationFeed.Gets or sets the base URI for the SyndicationFeed instance. |
| Categories |
Obtém uma coleção de categorias para o feed.Gets a collection of categories for the feed. |
| Contributors |
Obtém uma coleção dos colaboradores do feed.Gets a collection of the contributors to the feed. |
| Copyright |
Obtém ou define as informações de direitos autorais para o feed.Gets or sets copyright information for the feed. |
| Description |
Obtém ou define uma descrição do feed.Gets or sets a description of the feed. |
| Documentation |
Obtém ou define o link para a documentação do feed.Gets or sets the link to documentation for the feed. |
| ElementExtensions |
Obtém as extensões de elemento do feed.Gets the element extensions for the feed. |
| Generator |
Obtém ou define o gerador do feed.Gets or sets the generator of the feed. |
| Id |
Obtém ou define a ID do feed.Gets or sets the ID of the feed. |
| ImageUrl |
Obtém ou define a URL de imagem para o feed.Gets or sets the image URL for the feed. |
| Items |
Obtém uma coleção dos itens de feed contidos no feed.Gets a collection of the feed items contained in the feed. |
| Language |
Obtém ou define o idioma do feed.Gets or sets the language of the feed. |
| LastUpdatedTime |
Obtém ou define a hora em que o feed foi atualizado pela última vez.Gets or sets the time the feed was last updated. |
| Links |
Obtém os links associados ao feed.Gets the links associated with the feed. |
| SkipDays |
Obtém uma coleção de cadeias de caracteres que indica o conjunto de valores no elemento 'skipDays' para o feed.Gets a collection of strings indicating the set of values in the 'skipDays' element for the feed. |
| SkipHours |
Obtém uma coleção de inteiros que indicam o conjunto de valores no elemento 'skipHours' para o feed.Gets a collection of integers indicating the set of values in the 'skipHours' element for the feed. |
| TextInput |
Obtém ou define a propriedade TextInput do feed.Gets or sets the TextInput property for the feed. |
| TimeToLive |
Obtém ou define o atributo 'ttl' para o feed.Gets or sets the 'ttl' attribute for the feed. |
| Title |
Obtém ou define o título do feed.Gets or sets the title of the feed. |
Métodos
| Clone(Boolean) |
Cria uma cópia da instância SyndicationFeed.Creates a copy of the SyndicationFeed instance. |
| CreateCategory() |
Cria uma nova instância SyndicationCategory.Creates a new SyndicationCategory instance. |
| CreateItem() |
Cria uma nova instância SyndicationItem.Creates a new SyndicationItem instance. |
| CreateLink() |
Cria uma nova instância SyndicationLink.Creates a new SyndicationLink instance. |
| CreatePerson() |
Cria uma nova instância SyndicationPerson.Creates a new SyndicationPerson instance. |
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object. (Herdado de Object) |
| GetAtom10Formatter() |
Obtém uma instância de Atom10FeedFormatter.Gets an Atom10FeedFormatter instance. |
| GetHashCode() |
Serve como a função de hash padrão.Serves as the default hash function. (Herdado de Object) |
| GetRss20Formatter() |
Obtém uma instância de Rss20FeedFormatter.Gets an Rss20FeedFormatter instance. |
| GetRss20Formatter(Boolean) |
Obtém uma nova instância de Rss20FeedFormatter.Gets a new Rss20FeedFormatter instance. |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| Load(XmlReader) |
Carrega um feed de sindicalização do leitor de XML especificado.Loads a syndication feed from the specified XML reader. |
| Load<TSyndicationFeed>(XmlReader) |
Carrega uma instância derivada do SyndicationFeed do XmlReader especificado.Loads a SyndicationFeed-derived instance from the specified XmlReader. |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| SaveAsAtom10(XmlWriter) |
Gravar o feed de sindicalização no XmlWriter especificado no formato Atom 1.0.Write the syndication feed to the specified XmlWriter in Atom 1.0 format. |
| SaveAsRss20(XmlWriter) |
Gravar o feed de sindicalização no XmlWriter especificado no formato RSS 2.0.Write the syndication feed to the specified XmlWriter in RSS 2.0 format. |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object. (Herdado de Object) |
| TryParseAttribute(String, String, String, String) |
Tenta analisar uma extensão de atributo.Attempts to parse an attribute extension. |
| TryParseElement(XmlReader, String) |
Tenta analisar uma extensão de elemento.Attempts to parse an element extension. |
| WriteAttributeExtensions(XmlWriter, String) |
Grava as extensões de atributo no XmlWriter especificado usando a versão de sindicalização especificada.Writes the attribute extensions to the specified XmlWriter using the specified syndication version. |
| WriteElementExtensions(XmlWriter, String) |
Grava as extensões de elemento no XmlWriter especificado usando a versão de sindicalização especificada.Writes the element extensions to the specified XmlWriter using the specified syndication version. |