Jump to content

tweaking the xml content


spangle1187

Recommended Posts

Is there a way that I can tweak the following code so that the root nodes have different names?

 

At the moment the xml file is creating a root node for each booking called booking so when I take the xml into flash it is calling it badly formed xml due to the repitition of <booking></booking>

 

//sql_query
$table_id = 'booking'; 	
$query = "SELECT * FROM $table_id WHERE (booking.bookingDate = curDate()) AND roomID = 1 ORDER BY startTime";
$room1 = mysql_query($query);


//create a new DOM document
$doc = new DOMDocument('1.0');

//create root element
$root = $doc->createElement('root');
$root = $doc->appendChild($root);

//process one row at at time
while($row = mysql_fetch_assoc($room1)){

//add node for each row
$occ = $doc->createElement($table_id);
$occ = $doc->appendChild($occ);

//add achild for each field
foreach ($row as $fieldname => $fieldvalue){

     $child = $doc->createElement($fieldname);
    	$child = $occ->appendChild($child);


$value = $doc->createTextNode($fieldvalue);
    	$value = $child->appendChild($value);
}
}

   $xml_string = $doc->saveXML();

echo $xml_string;

mysql_free_result($room1);
?>

Link to comment
https://forums.phpfreaks.com/topic/226441-tweaking-the-xml-content/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.