Typo...
| From: | Simon Harper | Date: | Mon, 23 Jan 2012 20:38:14 +0000 |
| Subject: | Typo... | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-12891@lists.php.net to get a copy of this message | ||
Hi Friends...
Just a quick one, not sure if you care but spotted an error in the basic
SimpleXML tutorial :
Example #10 Adding elements and attributes
Since PHP 5.1.3, SimpleXML has had the ability to easily add children and
attributes.
<?php
include 'example.php';
$movies = new SimpleXMLElement($xmlstr);
$character = $movies->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 $movies->asXML();
?>
...and I didnt feel like a complete anorak before pointing this out, now I
do!
Thanks for such an excellent manual! It has really helped me to prepare for
ZCE.
Cheers guys
Simon