Hello,
I wrote xml to a file using php, and then I sent the file data as a response to the client's browser. But, I'm getting the following error: XML Parsing Error: not well-formed Below, is my code. Any way to fix this?
$file= fopen("result.xml", "w");
$_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
$_xml .="<friends>";
$timestamp = time();
$_xml.="<date>".date("F jS, Y", $timestamp)."</date>"; //Like December 23rd, 2009
$_xml .="<total>".$totalResults."</total>";
foreach($friendList as $key => $value) { /*$friendList contains key value pairs*/
$_xml.="<friend>";
$_xml.="<name>".$key."</name>";
$_xml.="<webpage>".$value."</webpage>";
$_xml.="</friend>";
}
$_xml .="</friends>";
fwrite($file,$_xml);
fclose($file);
//Send the xml file as response
header('Content-type: text/xml');
readfile('result.xml');
Thank You