note 95080 added to simplexmlelement.xpath
| From: | henrik at diskotekglobe dot dk | Date: | Sat, 12 Dec 2009 16:39:19 +0000 |
| Subject: | note 95080 added to simplexmlelement.xpath | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163879@lists.php.net to get a copy of this message | ||
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"> ??
----
Server IP: 69.147.83.197
Probable Submitter: 87.54.128.139
----
Manual Page -- http://www.php.net/manual/en/simplexmlelement.xpath.php
Edit -- https://master.php.net/note/edit/95080
Del: integrated -- https://master.php.net/note/delete/95080/integrated
Del: useless -- https://master.php.net/note/delete/95080/useless
Del: bad code -- https://master.php.net/note/delete/95080/bad+code
Del: spam -- https://master.php.net/note/delete/95080/spam
Del: non-english -- https://master.php.net/note/delete/95080/non-english
Del: in docs -- https://master.php.net/note/delete/95080/in+docs
Del: other reasons-- https://master.php.net/note/delete/95080
Reject -- https://master.php.net/note/reject/95080
Search -- https://master.php.net/manage/user-notes.php