edit xml with php?
| From: | Jan Grafstrom | Date: | Tue, 17 Jul 2001 10:27:30 +0000 |
| Subject: | edit xml with php? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-58245@lists.php.net to get a copy of this message | ||
Hi!
I am trying to edit this xml-file:
I want to change one of the li-nodes.
<?xml version="1.0"?>
<kund>
<li>
<na>per</na>
<en>Bylund</en>
<ga>Semin</ga>
</li>
<li>
<na>Axel</na>
<en>Timan</en>
<ga>Semina</ga>
</li>
<li>
<na>Lars</na>
<en>Berg</en>
<ga>Seminar</ga>
</li>
</kund>
-------------
I have tryed to read and explode on "</li>"
$fd = fopen($filename, "r");
$string = fread($fd, filesize($filename));
$fru = explode ("</li>", $string);
for ($i=0;$fru[$i];++$i) {
$newfru = ("$fru[$i]"."</li>");
$newfru =
str_replace("</kund>"."\r\n"."</li>","</kund>",$newfru);
print $newfru;
}
How to replace one of the $fru[i], I have tryed inside the forloop but
than it replaces all.
Thanks in advance for any help.
Regards
Jan