Hi. I had some old DOM XML functions in my php code. Could someone tell me how to use new functions to replace old one? I read the php manual and tried but it didn't work. Here is my simple php code, not long 🙂
<?
//link the database server
....
//Run the query
$query = "";
$mysql_result=mysql_query($query,$mysql_link);
$row = mysql_fetch_array($mysql_result);
$name = $row["name"];
$description = $row["description"];
$query = "";
$mysql_result=mysql_query($query,$mysql_link);
$rows = mysql_num_rows($mysql_result);
// Create XML document
if($rows>0)
{
//Create DOM Object
$doc =domxml_new_doc("1.0");
//Add root node and child node
$root = $doc->add_root("data");
$child = $root->new_child("title",$name);
$child = $root->new_child("description",$description);
//Iterate through results
for ($x=1; $x <= $rows; $x++)
{
$row = mysql_fetch_array($mysql_result);
$questiontext = $row["question"];
$questionid = $row["id"];
$filename = $row["filename"];
$child = $root->new_child("question","");
$child->set_attribute("id",$questionid);
$child->new_child("qtext",$x.$questiontext);
}
//Dumpxml doc to a string
$xml_string = $doc->dumpmem();
}
mysql_close($mysql_link);
//print xml
echo $xml_string;
?>