Here is my code:
public function xmlExport(){
$xml = new \SimpleXMLElement('<xml/>');
for ($i = 1; $i <= 8; ++$i) {
$track = $xml->addChild('track');
$track->addChild('path', "تست ");
$track->addChild('title', "Track $i - Track Title");
}
Header('Content-type: text/xml');
print($xml->asXML());
}
When I run code above, it prints something in the current browser page. But I want to make a .xml
file of that which is downloadable .. Is doing that possible by PHP?