note 95080 rejected from simplexmlelement.xpath by danbrown

From: Date: Sat, 12 Dec 2009 18:41:32 +0000
Subject: note 95080 rejected from simplexmlelement.xpath by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-163886@lists.php.net to get a copy of this message
Note Submitter: henrik at diskotekglobe dot dk ---- Hello can some of you tell me how to edit a xml file i am using this to create one: <?php $xml = simplexml_load_file("test.xml"); $sxe = new SimpleXMLElement($xml->asXML()); $news = $sxe->addChild("news"); $news->addAttribute("no", "3"); $news->addChild("name", "Henrik"); $news->addChild("age", "22"); $sxe->asXML("test.xml"); ?> This script is making the last sekseion in this xml: <?xml version="1.0" encoding="UTF8"?> <newst> <news no="1"> <name>ole</name> <age>99</age> </news> <news no="2"> <name>Maria</name> <age>18</age> </news> <news no="3"> <name>Henrik</name> <age>22</age> </news> </newst> But how can i change <news no"2"> ??

« previous php.notes (#163886) next »