I am trying to make a main webclient call to get the xml stream for a message tracking application for WP7. It works, and I get xml, but the problem is, since I live in Sweden, we have special characters like å ö ä, etc., And for these characters I only get a box with a question mark inside.
The xml file I want to get looks like this:
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?> <pactrack version="2.0" date="Sat Jan 14 18:29:26 CET 2012" size="2125" lang="SE"> <header> <noofparcelentries>1</noofparcelentries> ...
So the encoding is ISO-8859-1, and I think this is my problem. I tried to read here on the forum for a solution, and some say that the format is supported, and some do not: Read iso-8859-1 C # WP7 RSS feed
I tried to add excellent encodings to the client, but nothing helps, my xml always skips special characters. However, there is a strange behavior that causes me if I add the wrong tracking number, and instead of numbers placed in special characters, I can suddenly read some special characters, the xml that I get from the server is an error message containing the tracking number , see below, but the xml definition is the same.
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> <pactrack version="2.0" date="Sat Jan 14 18:34:43 CET 2012" size="389" lang="SE" > <header> <noofparcelentries>1</noofparcelentries> <noofuniqueparcels>1</noofuniqueparcels> </header> <body> <parcel id="8538öööåå54248SE"> //I can read this road of xml suddenly <customerref></customerref> <internalstatus>0</internalstatus>
Does anyone have any ideas? I am new and completely lost this problem, so any help would be greatly appreciated! Is there a difference in the first xml and the second? It seems to me, maybe I don’t see special charters that are nested in the nodes, maybe the problem?
WebClient client = new WebClient(); public MainPage() { InitializeComponent(); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted); } void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { if (e.UserState as string == "mobiforge") { txtStatus.Text = e.BytesReceived.ToString() + "bytes received."; } } public void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error == null && !e.Cancelled) { MessageBox.Show(e.Result); } } private void btnDownload_Click(object sender, RoutedEventArgs e) { client.DownloadStringAsync(new Uri("http://server.logistik.posten.se/servlet/PacTrack?lang=SE&kolliid=85380954248SE"), "posten"); }