if you want to convert data to XML, it might be easier (and faster) to just sequentially put the XML tags on a string. for example:
<?php
$xml = '<?xml version="1.0" encoding="UTF-8"?><mydata>';
$sql = 'SELECT * FROM `table`';
$r = mysql_query ($sql);
while ($row=mysql_fetch_assoc ($r) ){
$xml .= '<row>';
foreach ($row as $field=>$value){
$xml .= '<field name="'.htmlspecialchars ($field).'" value="'.htmlspecialchars ($value).'"/>';
}
$xml .= '</row>';
}
$xml .= '</mydata>';
// let's output it for this example
header ('Content-type: text/xml; charset=UTF-8');
echo $xml;