LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   MySQL to XML - charset problems (https://www.linuxquestions.org/questions/programming-9/mysql-to-xml-charset-problems-314483/)

Boby 04-18-2005 08:29 AM

MySQL to XML - charset problems
 
Hello!

I have to transfer all informations from a huge MySQL table to an XML file. The MySQL charset is ISO-8859-1 [german] . There are also some special characters, most of them are russian or bulgarian letters, <= in one character [I'm not able to display it here too], and so on. When I try to read from the XML file with an XML parser in PHP or just to display the file in Firefox or another browser, I get errors because of this chars. Is there a way to delete all this chars or replace them with good ones with an PHP script? I also tried to set the XML encoding to UTF-8 but I get the same errors.

Thank you!
Boby

deiussum 04-20-2005 08:22 AM

Not sure about extended character sets offhand, but the following standard ASCII characters need to be translated as so:

< becomes &lt;
> becomes &gt;
& becomes &amp;amp;

For instance, if you have the following XML:
Code:

<blah>
    <b1>Me & You</b1>
    <b1>2 > 1</b1>
    <b1>2 < 4</b1>
</blah>

It would need to be encoded as so:
Code:

<blah>
    <b1>Me &amp;amp; You</b1>
    <b1>2 &gt; 1</b1>
    <b1>2 &lt; 4</b1>
</blah>

Edit: Had to encode my &amp;amp; twice above because the HTML was translating it! :)


All times are GMT -5. The time now is 10:56 PM.