943,717 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1137
  • C# RSS
Sep 14th, 2009
0

XML and unicode

Expand Post »
Hello!

Is there a way to parse xml content to unicode format?
I'm getting this:
Quote ...
"Minél nagyobb a család, annál nehezebb az újdonsült barátnak-barátnőnek beilleszkedni."
But I'd like this:
Quote ...
"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!
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
konczuras is offline Offline
59 posts
since Oct 2008
Sep 14th, 2009
2

Re: XML and unicode

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.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 15th, 2009
0

Re: XML and unicode

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.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Sep 15th, 2009
0

Re: XML and unicode

Thank you or the answers, here is my code:


C# Syntax (Toggle Plain Text)
  1. public class RssData
  2. {
  3. public string title { get; set; }
  4. public string description { get; set;}
  5. public string link { get; set; }
  6. public DateTime pubDate { get; set; }
  7. public string source { get; set; }
  8. }
  9.  
  10. private void Button_Click(object sender, RoutedEventArgs e)
  11. {
  12. WebClient cli = new WebClient();
  13. Uri url = new Uri(linkbox.Text.ToString());
  14. cli.DownloadStringCompleted += new DownloadStringCompletedEventHandler(cli_DownLoadStringCompleted);
  15. cli.DownloadStringAsync(url);
  16. }
  17.  
  18. private void cli_DownLoadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
  19. {
  20. XDocument xdoc = XDocument.Parse(e.Result,LoadOptions.None);
  21.  
  22. var rssFeed = from story in xdoc.Descendants("item")
  23. select new RssData
  24. {
  25. title = (story.Element("title").Value.ToString()),
  26.  
  27. description = StripHTML(((string)story.Element("description"))),
  28. link = (string)story.Element("link"),
  29. pubDate = (DateTime)story.Element("pubDate"),
  30. source=(string)story.Element("link").Parent.Element("title")
  31.  
  32.  
  33. };
  34. Array ase= rssFeed.ToArray();
  35.  
  36. datag.ItemsSource = ase;
  37. }

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

Have you got any suggestions about how should I do it?
Last edited by konczuras; Sep 15th, 2009 at 5:14 am.
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
konczuras is offline Offline
59 posts
since Oct 2008
Sep 15th, 2009
0

Re: XML and unicode

Oh, I forgot to mention that I've wrote the content to my console like this:
C# Syntax (Toggle Plain Text)
  1. Console.WriteLine(XDocument.Parse(e.Result));
And this isn't good as well. The same strange characters are in it too.
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
konczuras is offline Offline
59 posts
since Oct 2008
Sep 17th, 2009
0

Re: XML and unicode

Is this RSS feed online? Can you post enough code where we can run this example and see the problem?
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: From bringToFront
Next Thread in C# Forum Timeline: Header Check box in data grid view is not working





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC