SimpleXMLElement problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I am trying to run examples in the but I am getting the error

Fatal error: Call to undefined method SimpleXMLElement::addChild()

The example is as follows

$xml = new SimpleXMLElement($xmlstr);

$character = $xml->movie[0]->characters->addChild('character');
$character->addChild('name', 'Mr. Parser');
$character->addChild('actor', 'John Doe');

$rating = $xml->movie[0]->addChild('rating', 'PG');
$rating->addAttribute('type', 'mpaa');

echo $xml->asXML();

Does anyone konw whats going on here?

Site Timeline