Hello!

Is there a way to parse xml content to unicode format?
I'm getting this:

"Minél nagyobb a család, annál nehezebb az újdonsült barátnak-barátnőnek beilleszkedni."

But I'd like this:

"Minél nagyobb a család, annál nehezebb az újdonsült barátnak-barátnőnek beilleszkedni."

I'm using a web service to download an rss feed asynchronously to a WPF datagrid, and I get all the texts in the above format.
What could I do?
I've tried the HttpUtiliy.HtmlDecode(), but did no good at all.

Thanks in advance!

Recommended Answers

All 5 Replies

I've question when it loses its format? try to catch the message returned from xml webservice and see if it comes in the right format or not? I just want to put my hand on the phase content loses its format.

commented: welcome back +8
commented: welcome back! +14

Also post the code you are using to fetch the RSS feed. Somewhere along the way you may be missing an opportunity to specify the proper encoding.

Thank you or the answers, here is my code:

public class RssData
        {   
            public string title { get; set; }
            public string description { get; set;}
            public string link { get; set; }
            public DateTime pubDate { get; set; }
            public string source { get; set; }
        }
  
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            WebClient cli = new WebClient();
            Uri url = new Uri(linkbox.Text.ToString());
            cli.DownloadStringCompleted += new DownloadStringCompletedEventHandler(cli_DownLoadStringCompleted);
            cli.DownloadStringAsync(url);
        }

        private void cli_DownLoadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
           XDocument xdoc = XDocument.Parse(e.Result,LoadOptions.None);
            
            var rssFeed = from story in xdoc.Descendants("item")
                          select new RssData
                          {
                              title = (story.Element("title").Value.ToString()),
                     
                              description = StripHTML(((string)story.Element("description"))),
                              link = (string)story.Element("link"),
                              pubDate = (DateTime)story.Element("pubDate"),
source=(string)story.Element("link").Parent.Element("title")


                          };
            Array ase= rssFeed.ToArray(); 

            datag.ItemsSource = ase;
        }

SrtipHTML is a string() method which returns a string without the html tags.

Have you got any suggestions about how should I do it?

Oh, I forgot to mention that I've wrote the content to my console like this:

Console.WriteLine(XDocument.Parse(e.Result));

And this isn't good as well. The same strange characters are in it too.

Is this RSS feed online? Can you post enough code where we can run this example and see the problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.