Need help with xml file to edit content for my flash site, every time when I insert into textarea for example "name" it create new activity in xml and I need that it would change from "swimming" to "name". I have found out that to change content in xml I need to delete "swimming" and to insert "Name" .
How to do it, first to insert content into textarea --> save it when you press "update" --> delete old activity from xml file and than to insert new content into xml file????
örnek.xml
<?xml version="1.0"?>
<list>
<activity>swimming</activity>
</list>
index.php
<html>
<head><title>test</title></head>
</head>
<body>
<table width="100" border="1">
<tr>
<td><?php
$xmldoc = new DOMDocument();
$xmldoc->load("örnek.xml", LIBXML_NOBLANKS);
$activities = $xmldoc->firstChild->firstChild;
if($activities!=null){
while($activities!=null){
echo $activities->textContent."";
$activities = $activities->nextSibling;
}
}
?></td>
</tr>
<tr>
<td><form name="input" action="insert.php" method="post">
<textarea name="activity" cols="70" rows="10"><?php
$xmldoc = new DOMDocument();
$xmldoc->load("örnek.xml", LIBXML_NOBLANKS);
$activities = $xmldoc->firstChild->firstChild;
if($activities!=null){
while($activities!=null){
echo $activities->textContent."";
$activities = $activities->nextSibling;
}
}
?></textarea>
</td>
</tr>
<tr>
<td align="right"><input type="submit" value="Update"/>
<input name="reset" type="reset" id="reset" value="Reset">
</form></td>
</tr>
</table>
</body>
</html>
insert.php
<?php
header('Location:index.php');
$xmldoc = new DOMDocument();
$xmldoc->load('örnek.xml');
$newAct = $_POST['activity'];
$root = $xmldoc->firstChild;
$newElement = $xmldoc->createElement('activity');
$root->appendChild($newElement);
$newText = $xmldoc->createTextNode($newAct);
$newElement->appendChild($newText);
$xmldoc->save('örnek.xml');
?>
Yardımlarınız için teşekkür ederiz!