Hi, I have to create a XML file but I don’t know how to do that with Yii.
Can someone explain how to do that? I need a XML to store in a/path/of/the/server
TIA!
Danilo
Hi, I have to create a XML file but I don’t know how to do that with Yii.
Can someone explain how to do that? I need a XML to store in a/path/of/the/server
TIA!
Danilo
I would appreciate this too. cheers
you can create an action on your controller like…
public function actions() {
return array(
'xml'=>'application.controllers.docs.xmlAction',
);
}
then create a xml doc
header("Content-type: text/xml;charset=utf-8");
$s = "<?xml version='1.0' encoding='utf-8'?>";
$s .= "<rows>";
$s .= "<records>".$count."</records>";
foreach($result as $n=> $row):
$s .= "<row id='". $row->$fieldID."'>";
$s .= "<cell>". $row->$field."</cell>";
$s .= "</row>";
endforeach;
$s .= "</rows>";
header("Content-Type: application/xml");
header("Content-Length: " . strlen($s));
echo $s;
or
$xml = new SimpleXMLElement("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
$tmp = $xml->addChild(‘data’, $res->RecordCount());
foreach($res as $row) {
$node = $xml->addChild('prospect');
$node->addChild($field, $row[$field]);
}
echo $xml->asXML();
Zend Framework has related components, which you can freely integrate with Yii. It’s not very confidential, so I can say that XML generation and aggregating is planned in the new extension library.