[英]Reading non standard tags in a RSS feed
我正在嘗試為Ferrari網站編寫RSS提要,但我無法使用SyndicationItem讀取全部內容。 問題在於方法getContent()僅讀取<link>
, <title>
和<description>
元素(它們都是<item>
子代)。 我也需要閱讀的內容<textnews>
元素中,孩子<item>
我必須修改此查詢:
feed.LoadFromXml(feedXML);
// Query LINQ per effettuare il mapping
return feed.Items.ToList().Select(x =>
new FeedItem
{
Title = x.Title.ExtractText(),
Uri = x.GetUri(),
Id = (x.ItemUri != null) ? x.ItemUri.ToString() : x.Title.ExtractText(),
PubDate = x.PublishedDate.ToLocalTime().DateTime,
Content = x.GetContent(),
PlainTextContent = x.GetContent().ToPlainText(),
Subtitle = string.Empty,
ContentType = x.GetContentType(),
}).ToList();
你能幫助我嗎?
您需要將文檔解析為XDocument,然后解析每個節點。 例如:
var doc = XDocument.Load(aString);
var news = doc.Element("textnews").InnerText;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.