阅读自定义RSS标记

时间:2015-12-03 13:25:12

标签: c# rss

我对编程比较陌生,我正在尝试编写一个程序,从rss文档中获取项目,并将我想要的内容输出到Datagrid和Teamspeak中。到目前为止,我能够获取项目的标题并从标题中删除分钟,因为有一个自定义的RSS标记,上面写着:wf:expiry

我的问题是我现在无法访问该元素。 我的方法是获得到期时间,获取当前DateTime,创建时间长度为timevalid = expiry - current然后只倒计时timevalid--然后将其移交给我的UpdateData函数UpdateData(subject, timevalid--);

public void GetData()
{
    // set the RSS URL and init the XML Reader
    string url = "http://content.warframe.com/dynamic/rss.php";
    XmlReader reader = XmlReader.Create(url);
    SyndicationFeed feed = SyndicationFeed.Load(reader);
    reader.Close();

    foreach (string s in feed.ElementExtensions.ReadElementExtensions<string>("wf:expiry", ""))
    {
        ConnectionLabel.Content = s;
    }

    // go thru each item
    foreach (SyndicationItem item in feed.Items)
    {
        String subject = item.Title.Text;
        // Adding the Item if the ID isnt already added
        if (!listRSS.ContainsKey(item.Id))
        {
            // remove the Minute Label from the Title to prepare parsing the expiry date and use this as the basis of the timer
            if (subject.EndsWith("m"))
            {
                // this will remove all characters in the string.
                // pattern would be "data - XXm" so remove the " - XXm" part
                char[] blacklist = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'm', '-', ' ' };
                subject = subject.TrimEnd(blacklist);
            }
            // add the ID to listRSS to be able to compare the GUID of the Alert to the ones in the List to avoid adding Alerts that had been already added
            listRSS.Add(item.Id, subject);
            // hand over the subject to update the Datagrid
            UpdateData(subject);
        }
    }
}

所以我的问题是,我可以移交带有时间的Datagrid插件 - 所以它会减少wpf应用程序中的时间吗?

我希望了解如何访问wf:expiry元素并解析其内部以将其转换为DateTime。我希望有一个解决方案,如果有人能够做到这一点,所以我可以阅读代码并看到方法。

我刚刚通过贡献github来学习这一切,但我主要做了xaml代码,因为我对UI更感兴趣。这是我的第一个项目。

0 个答案:

没有答案