09-27-2007, 12:07 AM
|
#3 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,239
Thanks: 3
|
I don't know about being more readable but you could replace the bunch of code under the // XML comment with this DOM code (just an example).
PHP Code:
// Create our document
$pDom = new DOMDocument('1.0', 'utf-8');
$pRoot = $pDom->appendChild($pDom->createElement('diary'));
$pRaw = $pRoot->appendChild($pDom->createElement('raw'));
// Create <superstar> nodesets
while ($row = mysql_fetch_array($raw))
{
$pStar = $pRaw->appendChild($pDom->createElement('superstar'));
$pStar->appendChild($pDom->createElement('id', $row['id']));
$pStar->appendChild($pDom->createElement('name', $row['name']));
$pStar->appendChild($pDom->createElement('status', $row['status']));
$pStar->appendChild($pDom->createElement('alignment', $row['alignment']));
}
// Output formatted XML
header('Content-type: text/xml');
$pDom->formatOutput = true;
echo $pDom->saveXML();
__________________
salathe@php.net
|
|
|
|