SyndicationItem.Categories 屬性

定義

取得新聞訂閱項目的新聞訂閱分類。

public:
 property System::Collections::ObjectModel::Collection<System::ServiceModel::Syndication::SyndicationCategory ^> ^ Categories { System::Collections::ObjectModel::Collection<System::ServiceModel::Syndication::SyndicationCategory ^> ^ get(); };
public System.Collections.ObjectModel.Collection<System.ServiceModel.Syndication.SyndicationCategory> Categories { get; }
member this.Categories : System.Collections.ObjectModel.Collection<System.ServiceModel.Syndication.SyndicationCategory>
Public ReadOnly Property Categories As Collection(Of SyndicationCategory)

屬性值

Collection<SyndicationCategory>

表示新聞訂閱項目分類的 SyndicationCategory 物件集合。

範例

下列程式碼會示範如何將分類加入至 CategoriesSyndicationItem 集合。

SyndicationItem item = new SyndicationItem("Item Title", "Item Content", new Uri("http://Item/Alternate/Link"));
item.Categories.Add(new SyndicationCategory("MyFeedCategory"));
Dim item As New SyndicationItem("Item Title", "Item Content", New Uri("http:' Item/Alternate/Link"))
item.Categories.Add(New SyndicationCategory("MyFeedCategory"))

下列 XML 會說明具有分類的 SyndicationItem 執行個體如何序列化為 Atom 1.0。

<entry>
  <id>Item ID</id>
  <title type="text">My Item</title>
  <updated>2007-03-16T23:02:54Z</updated>
  <author>
    <name>Jesper Aaberg</name>
    <uri>http://contoso/Jesper</uri>
    <email>jesper@contoso.com</email>
  </author>
  <link rel="alternate" href="http://someserver/MyItem" />
  <link rel="alternate" type="text/html" title="Alternate Link" length="1000" href="http://otherserver/Item" />
  <category term="Category One" />
  <content type="text">This is some content</content>
</entry>

下列 XML 會說明具有分類的 SyndicationItem 執行個體如何序列化為 RSS 2.0。

<item>
  <guid isPermaLink="false">Item ID</guid>
  <link>http://someserver/MyItem</link>
  <author>lene@contoso.com</author>
  <category>Category One</category>
  <title>我的專案</title>

  <description>這是一些內容</description>
  <a10:link rel="alternate" type="text/html" title="Alternate Link" length="1000" href="http://otherserver/Item" />
  <a10:updated>2007-03-16T23:02:54Z</a10:updated>
</item>

備註

當序列化至 Atom 1.0 或 RSS 2.0 時,會針對 <category> 集合中的每個分類建立 Categories 項目。

適用於