I have a question about how to add a stylesheet to a SimpleXML generated XML file. This is my code, but I don't know how to add a stylesheet for this.
$xml = new SimpleXMLElement('<Cart/>');
$Order = $xml->addChild('Person');
$Order->addChild('Name', $_GET['name']);
$Order->addChild('Last-name', $_GET['lname']);
$Order->addChild('E-mail', $_GET['email']);
$Order->addChild('Phone', $_GET['phone']);
$Order->addChild('Date', date('Y-m-d'));
$Order->addChild('Adress', isset($_GET['adress'])&&$_GET['adress'] != NULL?$_GET['adress']:'Not set');
$Products = $xml->addChild('Products');
foreach ($cart as $product_id) {
foreach($productlist as $list){
if($list['id'] == $product_id){
$Cart = $Products->addChild('Product');
$Cart->addChild('ID', $list['id']);
$Cart->addChild('Brand', $list['brand']);
$Cart->addChild('Model', $list['model']);
$Cart->addChild('Price', $list['price']);
}
}
}
Header('Content-type: text/xml');
date_default_timezone_set("Europe/Helsinki");
$xml->asXML('orders/' .date('Y-m-d(H-i-s)'). '.xml');
And this is the line that I want to add to the top of my generated XML file.
<?xml-stylesheet type="text/xsl" href="order.xsl" ?>