我能够将自己的标签添加到 RSS 提要(通过阅读此问题中的答案),但现在我似乎无法访问代码中的标签。
我尝试修改一个已经存在的示例提要(这个),只添加一个标签,如下所示。
<?xml version="1.0"?>
<rss version="2.0" xmlns:my="http://tempuri.org">
<channel>
<title>Liftoff News</title>
<link>http://liftoff.msfc.nasa.gov/</link>
<description>Liftoff to Space Exploration.</description>
<item>
<title>Star City</title>
<link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link>
<description>How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's <a href="http://howe.iki.rssi.ru/GCTC/gctc_e.htm">Star City</a>.</description>
<pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>
<guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid>
<my:br_id>1507</my:br_id>
</item>
</channel>
</rss>
在代码中我有这个类:
public class SimpleSyndicationItem
{
public DateTimeOffset Date { get; set; }
public string Title { get; set; }
public Uri Link { get; set; }
public string Id{ get; set; }
public SimpleSyndicationItem(DateTimeOffset date, string title, Uri link, string id)
{
Date = date;
Title = title;
Link = link;
Id = id;
}
}
Id 属性应该接收 my:br_id 中的值,现在,在阅读过程中,我有这个:
var RssItems = new ObservableCollection<SimpleSyndicationItem>();
var reader = XmlReader.Create("rssexample.xml");
var feed = SyndicationFeed.Load(reader);
foreach(var item in feed.Items)
{
//This is the part where I want to access the tag's value, notice the ??
RssItems.Add(new SimpleSyndicationItem(item.PublishDate, item.Title.text,
item.Links[0].Uri, item.??));
}
至少智能感知没有显示 br_id 所以我想知道在代码中访问这个标签的正确方法是什么。