Some help with SimpleXML :`(
| From: | J DeBord | Date: | Fri, 04 Sep 2009 09:31:02 +0000 |
| Subject: | Some help with SimpleXML :`( | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-297664@lists.php.net to get a copy of this message | ||
On Fri, Sep 4, 2009 at 10:23 AM, Matthew Croud <matt@obviousdigital.com>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
>
>