You are here:  » XML feed characters


XML feed characters

Submitted by travelfrog on Sun, 2007-11-04 16:41 in

I have a feed that parses OK when I use the MagicParser Demo.

When I use MagicParser on the feed and store the feed data in MySql, some of the items have bad characters. One example is below.

This is what should be stored in MySql:
Loulé

This is what is actually being stored in MySql.
Loulé

Any ideas how I can correct this problem?

Submitted by support on Sun, 2007-11-04 18:15

Hi,

This is a character encoding issue. What it means is that the data in the feed is in a different character set to the HTML that your server / page is generating.

It is easily fixed. What you need to do is add a charset header to your page. The demo tool uses the utf-8 character set, so if your feed is displaying correctly with utf-8, the code you need to add to the very top of your script is:

  header("Content-Type: text/html; charset=utf-8");

This is PHP code, and must go before any other code so that the server can send the header before any content is generated.

Hope this helps!
Cheers,
David.

Submitted by travelfrog on Mon, 2007-11-05 21:02

Hi David,

My webpages are as follows

My Title Here

The problem was that the wrong characters were being stored in MySql. To get around this problem, I found a post on this forum that seems to have done the trick. I simply used the function utf8_decode before the xml data was inserted into MySql. The XML data now seems to be stored correctly in MySql.

Example:
'".utf8_decode($item["DESCRIPTIONS/DESCRIPTION_UK"])."'

The data now appears OK in my web pages, even though I use charset=iso-8859-1.