XML and unicode

Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2008
Posts: 58
Reputation: konczuras is an unknown quantity at this point 
Solved Threads: 1
konczuras konczuras is offline Offline
Junior Poster in Training

XML and unicode

 
0
  #1
Sep 14th, 2009
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!
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: XML and unicode

 
2
  #2
Sep 14th, 2009
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.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,442
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 626
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: XML and unicode

 
0
  #3
Sep 15th, 2009
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.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 58
Reputation: konczuras is an unknown quantity at this point 
Solved Threads: 1
konczuras konczuras is offline Offline
Junior Poster in Training

Re: XML and unicode

 
0
  #4
Sep 15th, 2009
Thank you or the answers, here is my code:


  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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 58
Reputation: konczuras is an unknown quantity at this point 
Solved Threads: 1
konczuras konczuras is offline Offline
Junior Poster in Training

Re: XML and unicode

 
0
  #5
Sep 15th, 2009
Oh, I forgot to mention that I've wrote the content to my console like this:
  1. Console.WriteLine(XDocument.Parse(e.Result));
And this isn't good as well. The same strange characters are in it too.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,442
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 626
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: XML and unicode

 
0
  #6
Sep 17th, 2009
Is this RSS feed online? Can you post enough code where we can run this example and see the problem?
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 384 | Replies: 5
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC