简体   繁体   English

C#试图从RSS提要中删除文本

[英]C# Trying to remove text from rss feed

Currently is have this code: 当前有此代码:

        if (caseStudyImages.SelectedIndex < 0)
        {
            caseStudyImages.SelectedIndex = 0;
        }

        var item = container.Items[caseStudyImages.SelectedIndex];
        subTitle.Text = item.Title.Text;

        HtmlDocument doc = new HtmlDocument();
        doc.LoadHtml(item.NodeValue);

        doc.DocumentNode.RemoveChild(doc.DocumentNode.FirstChild);

        StringBuilder sb = new StringBuilder();
        using (StringWriter writer = new StringWriter(sb))
        {
            doc.Save(writer);
        }

        item.NodeValue = doc.ToString();       

        caseStudyImages.ItemsSource = container.Items;

caseStudyImages is a flipview on the screen that contains an image and a webview item. caseStudyImages是屏幕上的翻页视图,其中包含图像和Webview项。 Container is my syndication feed item. 容器是我的联合供稿项目。 I am trying to remove the first node from the item currently selected, as it is text I do not want, and then display it in the webview. 我正在尝试从当前选定的项目中删除第一个节点,因为它是我不需要的文本,然后将其显示在Web视图中。 I am binding the webview content the the item.NodeValue in a DataTemplate. 我将Webview内容绑定到DataTemplate中的item.NodeValue。 My problem is on the line: item.NodeValue = doc.ToString(); 我的问题在网上:item.NodeValue = doc.ToString();
I get an exception throw saying "The method or operation is not implemented". 我抛出异常,说“未实现方法或操作”。 Does anyone have any suggestions? 有没有人有什么建议?

Do you have access to HtmlDocument class ? 您可以访问HtmlDocument类吗? Check the ToString ovveride maybe someone left NotImplementedException there. 检查ToString ovveride,也许有人在那里留下了NotImplementedException。

If you don't have access, then get the needed data from HtmlDocument that is considered to be NodeValue without using ToString(). 如果您没有访问权限,则可以从HtmlDocument获取被视为NodeValue的所需数据,而无需使用ToString()。 Use String.Format 使用String.Format

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM