Re: Typo...
| From: | Hannes Magnusson | Date: | Thu, 26 Jan 2012 15:32:32 +0000 |
| Subject: | Re: Typo... | ||
| References: | 1 | Groups: | php.webmaster |
| Request: | Send a blank email to php-webmaster+get-12955@lists.php.net to get a copy of this message | ||
On Mon, Jan 23, 2012 at 21:38, Simon Harper <harps.si@googlemail.com> wrote:
> 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!
Nice catch!
Fixed in SVN, will be updated tomorrow.
-Hannes