PHP to XML or just PHP

I know this is probably a matter of preference. I’m just wondering though if there is more ease and versatility in dynamically creating an xml sheet with PHP versus jsut echoing the PHP data somehow. What is the most efficient way of doing this? I’m trying to grab information from a mySQL database … and display it in flash…

[AS]
<?php
$query = ‘SELECT id, title, body
FROM Table
ORDER BY title DESC
LIMIT 999’;

$result = mysql_query($query);

$nl = “
”;
echo ‘<?xml version=“1.0” encoding=“ISO-8859-1”?>’ . $nl;
echo ‘<ROOT>’ . $nl;

while($r = mysql_fetch_array($result)){

echo '&lt;news id="' . $r['id'] . '" title="' . stripslashes2($r['title']) '"&gt;' . $nl;
echo '&lt;body&gt;&lt;![CDATA[' . stripslashes2($r['body']) . ']]&gt;&lt;/body&gt;' . $nl;
echo '&lt;/news&gt;' . $nl;

}

echo ‘</ROOT>’ . $nl;

?>
[/AS]
Obviously, u need to connect to your database, but that should provide u with the structure. have fun…