fork download
  1. <?php
  2.  
  3. // your code goes here
  4. $xml = new SimpleXMLElement('<xml/>', LIBXML_NOEMPTYTAG);
  5.  
  6. $output = $xml->addChild('child1');
  7. $output->addChild('child2', "value");
  8. $output->addChild('noValue', '');
  9.  
  10. echo $xml->asXML();
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
<?xml version="1.0"?>
<xml><child1><child2>value</child2><noValue/></child1></xml>