PDA

View Full Version : URLLoader RSS encoding Greek


psourt
01-09-2008, 08:03 PM
Hello,
I am trying to get a RSS feed using the URLLoader class. The page has Greek charachters and when I just trace the URLLoader data I see things like:

<?xml version="1.0" encoding="iso-8859-7"?>
<rss version="2.0">
<channel>
<title>H KAΘHMEPINH : ΠOΛITIKH</title>
<item>
<title>Χιλιάδες εκκρεμείς υποθέσεις στο ΣτΕ</title>
<link>http://news.kathimerini.gr/4dcgi/_w_articles_politics_0_09/01/2008_254817</link>
<pubDate>2008-1-9T09:05:06Z</pubDate>
<category>POLITICS</category>
<guid>http://news.kathimerini.gr/4dcgi/_w_articles_politics_0_09/01/2008_254817</guid>
<description><![CDATA[Σε μεγάλη πληγή του συστήματος απονομής δικαιοσύνης στη χώρα αναδεικνύονται οι τραγικές καθυστερήσεις κατά την έκδοση των δικαστικών αποφάσεων, που πλέον αγγίζουν και το Συμβούλιο της Επικρατείας. Σύμφωνα με τον πρόεδρο του ανώτατου ακυρωτικού δικαστηρίου... ...]]></description>
</item>

While the actual code from the source of the page I am trying to get is :

<?xml version="1.0" encoding="iso-8859-7"?>
<rss version="2.0">
<channel>
<title>H KAΘHMEPINH : ΠOΛITIKH</title>

<item>
<title>Χιλιάδες εκκρεμείς υποθέσεις στο ΣτΕ</title>
<link>http://news.kathimerini.gr/4dcgi/_w_articles_politics_0_09/01/2008_254817</link>
<pubDate>2008-1-9T09:05:06Z</pubDate>

<category>POLITICS</category>
<guid>http://news.kathimerini.gr/4dcgi/_w_articles_politics_0_09/01/2008_254817</guid>
<description><![CDATA[Σε μεγάλη πληγή του συστήματος απονομής δικαιοσύνης στη χώρα αναδεικνύονται οι τραγικές καθυστερήσεις κατά την έκδοση των δικαστικών αποφάσεων, που πλέον αγγίζουν και το Συμβούλιο της Επικρατείας. Σύμφωνα με τον πρόεδρο του ανώτατου ακυρωτικού δικαστηρίου... ...]]></description>
</item>


How can I encode the data so to look proper?

My code is:

import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.*;

var url:String = "http://wk.kathimerini.gr/xml_files/politics.xml" ;
var rssXMLURL:URLRequest = new URLRequest(url);
var myLoader = new URLLoader();
myLoader.dataFormat = URLLoaderDataFormat.TEXT;
myLoader.addEventListener(Event.COMPLETE, xmlLoaded);
myLoader.load(rssXMLURL);

function xmlLoaded(event:Event):void
{
trace(myLoader.data);

}


thanks,
Panos

panel
01-09-2008, 08:27 PM
Since xml file has encoding attribute there is a chance that it will fork after parsing xml


function xmlLoaded(event:Event):void
{
var xml:XML = new XML(evt.target.data);
trace(xml);
}

psourt
01-09-2008, 08:35 PM
Still the same problem.

psourt
01-10-2008, 02:05 PM
I got the solution through the use of PHP:

<?php
$xmlDoc = new DOMDocument();
$xmlDoc->load('http://ws.kathimerini.gr/xml_files/news.xml');
iconv("iso-8859-7","UTF-8",file_get_contents($file_to_convert)));
$string1 = $xmlDoc->saveXML();
$string2 = iconv("iso-8859-7","UTF-8",$string1);
echo "$string2";
?>

and then reading the php by using URLLoader

msti
10-01-2008, 03:49 PM
$string2 = iconv("iso-8859-7","UTF-8",$string1);

This worked for me as well!
Thanks!