Using PHP 4s DOM XML Functions to Create XML Files from SQL Data
By Tony Marston2005-04-04
Using Multi-Byte Characters
(1) Convert from default character set (refer to default_charset in file php.ini) to UTF-8 by inserting a single line as follows:
foreach ($row as $fieldname => $fieldvalue) {
$child = $doc->create_element($fieldname);
$child = $inner->append_child($child);
$value = mb_convert_encoding($value,'UTF-8','ISO-8859-1'); <<-- new line
$value = $doc->create_text_node($fieldvalue);
$value = $child->append_child($value);
} // foreach(2) To output the document correctly you must convert back to the default character set by amending the following line:
$xml_string = $doc->dump_mem(true, 'ISO-8859-1');NOTE: In order for this to work you must enable the Multi-Byte String functions in PHP.
Tutorial pages:
|
|
|||||||||
You might also want to check these out:
|
Leave a Comment on "Using PHP 4s DOM XML Functions to Create XML Files from SQL Data"
You must be logged in to post a comment.
Link to This Tutorial Page!

