[ad_1]
i have a problem with the code, i dont know what it is. When i click the edit button for the second node, the first node is displaying in edit and not the second one
<?php
$xml = new DOMDocument();
$xml->load('mystore.xml');
$element = $xml->getElementsByTagName('store')->item(0);
$itemcategory = $element->getElementsByTagName('itemcategory')->item(0);
$itemname = $element->getElementsByTagName('itemname')->item(0) ;
$itemdesc = $element->getElementsByTagName('itemdesc')->item(0) ;
$itemprice = $element->getElementsByTagName('itemprice')->item(0) ;
$itemquantity = $element->getElementsByTagName('itemquantity')->item(0) ;
$element->replaceChild($itemcategory, $itemcategory);
$element->replaceChild($itemname, $itemname);
$element->replaceChild($itemdesc, $itemdesc);
$element->replaceChild($itemprice, $itemprice);
$element->replaceChild($itemquantity, $itemquantity);
?>
<?php
if (isset($_POST['submit']))
{
$itemcategory->nodeValue = $_POST['itemcategory'];
$itemname->nodeValue = $_POST['itemname'];
$itemdesc->nodeValue = $_POST['itemdesc'];
$itemprice->nodeValue = $_POST['itemprice'];
$itemquantity->nodeValue = $_POST['itemquantity'];
htmlentities($xml->save('mystore.xml'));
header('location: adminpage.php');
}
?>
[ad_2]