RSSフィードに自分のタグを追加することはできましたが(この質問の回答を読んでから)、コードでタグにアクセスできないようになりました。
以下に示すように、既存のサンプルフィード(これ)を変更して、タグを1つだけ追加してみました。
<?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を表示していないので、コードでこのタグにアクセスする正しい方法は何でしょうか。