Hi there,
thanks for great class. Everything works fine, but about 30% of xml feeds I import has wrong characters. Strange is, that when i upload file into your demo, all seems to be all right. (for example entry number 6 contanins special characters)
The XML is http://www.chesslady.com/sm/xml/shop_nabidkaJyxo.xml
The first problem is, that there's no encoding specified. But it works in you demosite anyway, and it does'n work when I parse it even if I try to fill any of encodings used to show these characters (utf-8,windows-1250,iso-8859-2).
I've already found in the forum one solution, that does'n work in my case and it's header with encoding. My code is:
<?php
header("Content-Type: text/html;charset=utf-8");
require("MagicParser.php");
MagicParser_parse("http://www.chesslady.com/sm/xml/shop_nabidkaJyxo.xml","importData","xml|SHOP/SHOPITEM/");
function importData($row){
echo $row['PRODUCT'];
//i see this: ?achista za?�te?n�k. Z�klady modern�ho ?achu. instead of: Šachista začátečník. Základy moderního šachu.
}
?>
Catched headers:
GET /administrator/components/com_digger/functions/import.php?way=tmp&link_id=50&lang=utf-8 HTTP/1.1
Host: onlinezbozi.cz
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: __utmz=45347322.1194968288.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); __utma=45347322.84667950.1194968288.1195483104.1195496822.31; 9f6df9d69af406fb4e764117668f4f32=e85c1fcbce5f76ef0de123377fbd1b40
HTTP/1.x 200 OK
Date: Tue, 20 Nov 2007 08:44:41 GMT
Server: Apache/2.2.3 (Debian) PHP/4.4.4-8+etch4 mod_ssl/2.2.3 OpenSSL/0.9.8c
X-Powered-By: PHP/4.4.4-8+etch4
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html;charset=utf-8
I appreciate any help.
Hi,
thank you for response. The code above does not work for me :-((. I've sent more informations at support@iaaisoftware.com
Thank you
Hi,
As you say, the normal solution to this is the header() function in your script to make sure that the browser is using the correct character set.
On my server (as you can also see in the demo) this works, and the characters are displayed properly:
http://www.magicparser.com/examples/chesslady.php
Here is the source:
chesslady.php:
<?php
header("Content-Type: text/html;charset=utf-8");
require("MagicParser.php");
$count = 0;
function importData($row)
{
global $count;
echo $row['PRODUCT']."<br />";
$count++;
if ($count==20) return TRUE; // just show first 20 products
}
MagicParser_parse("http://www.chesslady.com/sm/xml/shop_nabidkaJyxo.xml","importData","xml|SHOP/SHOPITEM/");
?>
Could you please try that script exactly as it appears above on your server and see what is displayed?
If the characters are still not displayed correctly, can you email to me a link to the above code running on your server so that that I can take a look? Reply to your forum registration or reg code email is the easiest way to get me...
Cheers,
David.