XML

Creating XML files with PHP using SimpleXML is really easy, and elegant.

To create a SimpleXML object from a string, I use the following code.

$xml = simplexml_load_string("<?xml version='1.0'?>\n<phpsysinfo></phpsysinfo>");

From there it's really easy to expand.


$xml = simplexml_load_string("<?xml version='1.0'?>\n<phpsysinfo></phpsysinfo>");
$generation = $xml->addChild('Generation');
$generation->addAttribute('version', PSI_VERSION);
$generation->addAttribute('timestamp', time());