Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-18-2005, 08:29 AM   #1
Registered: Feb 2004
Location: Sighisoara/Cluj-Napoca (Romania)
Distribution: CentOS 4, Fedora Core 6
Posts: 781

Rep: Reputation: 32
MySQL to XML - charset problems


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!
Old 04-20-2005, 08:22 AM   #2
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
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:
    <b1>Me & You</b1>
    <b1>2 > 1</b1>
    <b1>2 < 4</b1>
It would need to be encoded as so:
    <b1>Me &amp;amp; You</b1>
    <b1>2 &gt; 1</b1>
    <b1>2 &lt; 4</b1>
Edit: Had to encode my &amp;amp; twice above because the HTML was translating it!

Last edited by deiussum; 04-20-2005 at 08:25 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
experiences with embedded mysql? XML instead of a database? SerfurJ Programming 2 12-11-2004 08:06 AM
XML <->MySql in Perl?? rsz Programming 0 10-06-2004 09:40 AM
html, xml, php, mysql atheist Programming 8 06-07-2004 01:28 PM
C++ question: MySQL or XML? BlackT Programming 7 07-21-2003 07:46 AM
Charset in MySQL YMJ Programming 1 03-26-2003 03:35 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:07 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration