簡體   English   中英

在RSS供稿中讀取非標准標簽

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM