954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

XML and unicode

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!

konczuras
Junior Poster in Training
59 posts since Oct 2008
Reputation Points: 10
Solved Threads: 1
 

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.

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

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.

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

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?

konczuras
Junior Poster in Training
59 posts since Oct 2008
Reputation Points: 10
Solved Threads: 1
 

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.

konczuras
Junior Poster in Training
59 posts since Oct 2008
Reputation Points: 10
Solved Threads: 1
 

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

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You