简体   繁体   中英

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. 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. I am binding the webview content the the item.NodeValue in a DataTemplate. My problem is on the line: 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 ? Check the ToString ovveride maybe someone left NotImplementedException there.

If you don't have access, then get the needed data from HtmlDocument that is considered to be NodeValue without using ToString(). Use String.Format

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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