hi, i need some help about how to delete nodes in my xml file, here is my xml
Code:
<products>
<product>
<category>switch</category>
<name>dgs105</name>
<price>2000</price>
<picture>networking/picture1.jpg</picture>
<description>rapid to respond</description>
</product>
<product>
<category>hub</category>
<name>dlink</name>
<price>1500</price>
<picture>networking/picture4.jpg</picture>
<description>ordinary</description>
</product>
</products>
and this is my php code to delete the node and also in the database where the name correspond:
Code:
<?php
$category=$_POST['txt_category'];
$name=$_POST['txt_name'];
include("db_connect.php");
if($name!="" && $name!=null){
$sql_delete="DELETE FROM products WHERE Category='$category' AND Name='$name'";
$result = (mysql_query($sql_delete));
$xdoc = new DOMDocument();
$xdoc->load('../xml/addproductxml.xml');
$product=$xdoc->getElementsByTagName('product');
$findname=$xdoc->getElementsByTagName('name');
foreach ($findname as $node){
$node->parentNode->removeChild($node);
}
$xdoc->save('../xml/addproductxml.xml');
}
?>
it does delete in my database but not in the xml and i cant really find the problem!! Please help