I am currently tring to follow a sitepoint tutorial but have run into difficulties .
Build an XML-Based Content Management System with PHP

i am getting an error from these lines of code
//create document root
$doc = domxml_new_doc("1.0");
$root = $doc->create_element("article");
$root = $doc->append_child($root); ************* line 5

Warning: domnode::append_child() expects parameter 1 to be object, null given in C:\xampp\htdocs\rss\cms_xml\addArticle.php on line 5
//add ID attribute
//FIRST, let's make sure that the id they chose isn't going to overwrite a file!
$dh = opendir('./xml/');

while ($file = readdir($dh)){
$string = $id .".xml\\";

if (eregi("^\\.\\.?$", $file)) {
if (eregi($string, $file)){
$time = date("U"); //num of seconds since unix epoch
$id = $id . "-" . $time;

$root->set_attribute('id', $id); ***************** Line 22.
Could anybody explain why i am getting these errors!
Fatal error: Call to a member function set_attribute() on a non-object in C:\xampp\htdocs\rss\cms_xml\addArticle.php on line 22