Hi all,

I've got this script which converts data from a mysql database to an xml object using the DOM and printing it out. Everything works fine, however some of the text contains ampersands (&) which gets printed as '&amp'

here's the script:
PHP Code:
function getdata($type)
$mysqHost "xxx";
$mysqlUsr "xxx";
$mysqlPass "xxx";
$conn mysql_connect($mysqHost,$mysqlUsr,$mysqlPass);
mysql_select_db("xxx") ;

$sql = ("SELECT * FROM `$type`;");
$result =  mysql_query($sql);
$doc = new DomDocument('1.0');
$type $str str_replace(' ','',$type);

$root $doc->createElement($type.'List');
$root $doc->appendChild($root);  
$row mysql_fetch_assoc($result))
$company $root->appendChild($company);    
$row as $fieldname => $fieldvalue)
$fieldname !='id')
$child $doc->createElement($fieldname);
$child $company->appendChild($child);
//add data to the new element
$value $doc->createTextNode($fieldvalue);
$value $child->appendChild($value);
//    $car->appendChild($doc->createElement($fieldname, $fieldvalue));  more efficient way of above
$str $doc->saveXML();


$type $_REQUEST['type'];

$conn){ mysql_close($conn); }
I've tried to decode $fieldValue using html_entity_decode, but it doesn't work. I really don't know how to fix this. Any help would be greatly appreciated.