Try to wright a xml with SimpleXmL. Need to nest some of the tags
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><orders></orders>'); $orderlist = $xml->addChild('order'); $orderlist->addAttribute('shipdate', date('Y-m-d H:i:s')); $orderlist = $xml->addChild('delivery'); $orderlist->addAttribute('weight', '0'); This will output this:
<?xml version="1.0" encoding="utf-8"?> <orders> <order shipdate="2017-10-11 13:44:12" /> <delivery weight="0" /> <order/> </orders> But need the tag not to close before the tag. Want it to look like this:
<?xml version="1.0" encoding="UTF-8"?> <orders> <order shipdate="2016-07-14T14:41:30"> <delivery weight="0" /> </order> </orders>