I am trying to read an rss feed that uses iso-8859-1 encoding.
I can get all the elements in order, the problem is when I put it in a text block, it will not display all the characters. I'm not sure what I'm doing wrong. I tried several solutions that I found on google, but this did not work for me. Something is missing for me. This is also the first time that I really work with anything other than utf-16. I never had to translate anything.
The application works as follows: downloadstring async (WebClient). Therefore, when this is called, I get a string containing the full RSS feed.
I tried to get bytes and then encoding.convert. But something is missing for me.
Like this example
WebClient RSS = new WebClient(); RSS.Encoding = Encoding.GetEncoding("ISO-8859-1"); RSS.DownloadStringCompleted += new DownloadStringCompletedEventHandler(RSS_DSC); RSS.DownloadStringAsync(new Uri("some rss feed")); public void RSS_DSC(object sender, DownloadStringCompletedEventArgs args) { _xml = XElement.Parse(args.Result); foreach(XElement item in _xml.Elements("channel").Elements("item")) { feeditem.title = item.Element("title").Value;
I tried this as well
private void RSS_ORC(object sender, OpenReadCompletedEventArgs args) { Encoding e = Encoding.GetEncoding("ISO-8859-1"); Stream ez = args.Result; StreamReader rdr = new StreamReader(ez, e); XElement _xml = _xml = XElement.Parse(rdr.ReadToEnd()); feedlist = new List<Code.NewsItem>(); XNamespace dc = "http://purl.org/dc/elements/1.1/"; foreach (XElement item in _xml.Elements("channel").Elements("item")) { Code.NewsItem feeditem = new Code.NewsItem(); feeditem.title = item.Element("title").Value; feeditem.description = item.Element("description").Value; feeditem.pubdate = item.Element("pubDate").Value; feeditem.author = item.Element(dc + "creator").Value; feedlist.Add(feeditem); } listBox1.ItemsSource = feedlist; }
Although the headers contain characters that are also not displayed. How .. I can make coding work partially. Instead of these characters: a square with a question mark, a question mark, or a square.
Do not misunderstand me. I am new to this. But the solutions that were published on the Internet do not solve it for me.
Please note that I deleted the encoding part because it did not work: / If someone can help me, it will be awesome.
source share