Some help with SimpleXML :`(

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 4, 2009 at 10:23 AM, Matthew Croud <matt@xxxxxxxxxxxxxxxxxx>wrote:

>
> Well, you guys are awesome.
>
> So the script below doesn't cause any errors (nice), however it doesn't
> save the newly added child to the xml file (items.xml):
>
>
>
> $xml = simplexml_load_file("items.xml");
>
> $item = $xml->addChild('item');
> $item->addChild('name', $name);
> $item->addChild('desc', $desc);
> $item->addChild('size', $size);
> $item->addChild('price', $price);
>
>
>
> I thought it would ?  would i need to "write" using fwrite ?
>
>
You'll need to save your xml to the file once you are done manipulating it.
Use $xml->asXML('filename'); Check here:
http://www.php.net/manual/en/simplexmlelement.asXML.php

J

>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux