3v4l.org

run code in 300+ PHP versions simultaneously
<?php //creating an XML document $dom = new DOMDocument('1.0'); $dom->xmlStandalone = false; //create element manifest $manfiestNode = $dom->createElement('manifest',""); $dom->importNode($manifestNode); //create attribute identifier $manfiestNodeAttr = $dom->createAttribute('identifier'); //value for the manifest node identifier value $date = new DateTime(); $manfiestNodeAttr->value = 'course_'.date_format($date,'U'); //append attribute to the manifest element $manfiestNode->appendChild($manfiestNodeAttr); $manfiestNode->appendChild($dom->createAttribute('xmlns:xsi'))->appendChild($dom->createTextNode("http://www.w3.org/2001/XMLSchema-instance")); //add metadata element under manifest node $metaData = $dom->createElement('metadata',''); //add metadata element to manifest node $manfiestNode->appendChild($metaData); //create schema and schemaversion element under metatag $schema = $dom->createElement('schema','ADL SCORM'); $schemaVersion = $dom->createElement('schemaversion', '2004 3rd Edition'); //create schema and schemaversion element under metatag $metaData->appendChid($schema); $metaData->appendChid($schemaVersion); //append manifest element to the document $dom->appendChild($manfiestNode); var_dump($dom->saveXML());

preferences:
28.27 ms | 402 KiB | 5 Q