this is my html code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
	
	 $xml = simplexml_load_file('../order1.xml');
     $products = $xml->xpath('/products/laptop');
	 
	 
	 foreach($products as $laptop) {

            if($_POST['list'] == $laptop->name) {
				
				global $lname,$detail,$price;
				
				   $lname  = $laptop->name;
				   $detail = $laptop->details; 
				   $price  = $laptop->price;
			}
     }
	 

	
?>  

<meta name="delete" content="deleting products" />
<title>index</title>
<link href="../includes/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>



<div class="Container">

<h1>The IT Portal</h1>

<div id="navbar"> 
  <ul> 
    <li><a href="../index.html">Home</a></li> 
    <li><a href="../products.html">Products</a></li> 
    <li><a href="../new_arrivals.html">New Arrivals</a></li> 
    <li><a href="../about.html">About us</a></li> 
    <li><a href="../Search.html">Search</a></li>
    <li><a href="../Register.html">Register</a></li>
    <li><a href="../login.html">LOGIN</a></li> 
  </ul> 
</div> 

<div id="con1">
<form action="update_p.php" method="post">
<table width="400" border="0" id="tab5">
  <tr>
  	<td colspan="2" align="center">
    
<select name="list" id="list" >
    
<?php
	
foreach($products as $name) {
			
		echo "<option>";
		echo $name->name;
		echo "</option>";
		
}

?>
      
    </select>
    </td>
  </tr>
  <tr>
    <td><label>Product Name</label></td>
    <td><?php echo "<input type=\"text\" name=\"p_name\" value=\"{$lname}\" >"; ?></td>
  </tr>  
  <tr> 
    <td><label>Details</label></td>
    <td><textarea name="" cols="" rows="2"><?php echo "$detail"; ?></textarea></td>
  </tr>
  <tr>
    <td>Price</td>
    <td><?php echo "<input type=\"text\" name=\"in_price\" value=\"{$price}\" >"; ?></td>
  </tr>
  
</table>

<input type="submit" value="edit" /><input name="" type="reset" />
</form>
</div>

<div class="push"></div>
 
</div>

<div class="footer">
      <p>It Portal (c) 2009</p>
</div>

</body>
</html>

this is my xml

<?xml version="1.0"?>
<?xml-stylesheet type = "text/xsl" href = "input.xsl"?>
<products>
    <laptop>
        <name>hp</name>
        <details>15.6-Inch Espresso Laptop - Up to 4 Hours of Battery Life (Windows 7 Home Premium)</details>
        <price>600$</price>
    </laptop>


    <laptop>
        <name>HP Pavilion DV6-1350US</name>
        <details>15.6-Inch Espresso Laptop - Up to 4 Hours of Battery Life</details>
        <price>600$</price>
    </laptop>
	
	<laptop>
        <name>Dell</name>
        <details>15.6-Inch Espresso Laptop</details>
        <price>600$</price>
    </laptop>
</products>

this is my php

<?php
$doc = new DOMDocument;
$doc->load('../order1.xml');

$laptops = $doc->getElementsByTagName('laptop');

foreach($laptops as $laptop)
{
   
   		$name    = $laptop->getElementsByTagName('name')->item(0)->textContent;
        $details = $laptop->getElementsByTagName('details')->item(0)->textContent;
        $price   = $laptop->getElementsByTagName('price')->item(0)->textContent;
		
        if($_POST['list'] == $name) {
		$doc->documentElement->removeChild($name);
		
		$names = $doc->createElement('name',$_POST['p_name']);
		$laptops->appendChild($names);

		}
		
}

$dom->save('../order1.xml');
?>

i need to edit my xml data and i don't know how, what i need to do the user will enter a new data in the text box so the old data will be removed and a new data will be add
i tried to modify the code that "Atli"(another member) helped me with but i failed.

I need some help to I need to edit this xml

<?xml version="1.0" encoding="utf-8"?>
<item>
   
    <list>
	<title>My daughter photo 1</title> 
	<description>images content demo for dynamic xml with lightbox,using images demo here.</description>
	<link>http://www.flashden.net/user/wangruyi</link>
     <thumb>thumb/2.jpg</thumb>
       <content width="" height="">contentpic/2.jpg</content>
   </list>
   <list>
	<title>My daughter photo 1</title> 
	<description>images content demo for dynamic xml with lightbox,using images demo here.</description>
	<link>http://www.flashden.net/user/wangruyi</link>
     <thumb>thumb/2.jpg</thumb>
       <content width="" height="">contentpic/2.jpg</content>
   </list>
   <list>
	<title>My daughter photo 1</title> 
	<description>images content demo for dynamic xml with lightbox,using images demo here.</description>
	<link>http://www.flashden.net/user/wangruyi</link>
     <thumb>thumb/2.jpg</thumb>
       <content width="" height="">contentpic/2.jpg</content>
   </list>
   <list>
	<title>My daughter photo 1</title> 
	<description>images content demo for dynamic xml with lightbox,using images demo here.</description>
	<link>http://www.flashden.net/user/wangruyi</link>
     <thumb>thumb/2.jpg</thumb>
       <content width="" height="">contentpic/2.jpg</content>
   </list>
   <list>
	<title>My daughter photo 1</title> 
	<description>images content demo for dynamic xml with lightbox,using images demo here.</description>
	<link>http://www.flashden.net/user/wangruyi</link>
     <thumb>thumb/2.jpg</thumb>
       <content width="" height="">contentpic/2.jpg</content>
   </list>
   <list>
	<title>My daughter photo 1</title> 
	<description>images content demo for dynamic xml with lightbox,using images demo here.</description>
	<link>http://www.flashden.net/user/wangruyi</link>
     <thumb>thumb/2.jpg</thumb>
       <content width="" height="">contentpic/2.jpg</content>
   </list>
   <list>
	<title>My daughter photo 1</title> 
	<description>images content demo for dynamic xml with lightbox,using images demo here.</description>
	<link>http://www.flashden.net/user/wangruyi</link>
     <thumb>thumb/2.jpg</thumb>
       <content width="" height="">contentpic/2.jpg</content>
   </list>
   <list>
	<title>My daughter photo 1</title> 
	<description>images content demo for dynamic xml with lightbox,using images demo here.</description>
	<link>http://www.flashden.net/user/wangruyi</link>
     <thumb>thumb/2.jpg</thumb>
       <content width="" height="">contentpic/2.jpg</content>
   </list>
   
   
  
   
   
  
</item>

Don't know if this helps but this file creates and .xml for me and works now I just need a form that will plugin the variables

<?php
  $item = array();
  $item [] = array(
  'title' => 'My daughter photo 1',
  'description' => 'images content demo for dynamic xml with lightbox,using images demo here.',
  'link' => "",
  'thumb' => "thumb/2.jpg",
  'content' => "contentpic/2a.jpg"
  );
   $item [] = array(
  'title' => 'My daughter photo 2',
  'description' => 'images content demo for dynamic xml with lightbox,using images demo here.',
  'link' => "",
  'thumb' => "thumb/2.jpg",
  'content' => "contentpic/3.jpg"
  );
    $item [] = array(
  'title' => 'My daughter photo 3',
  'description' => 'images content demo for dynamic xml with lightbox,using images demo here.',
  'link' => "",
  'thumb' => "thumb/2.jpg",
  'content' => "contentpic/4.jpg"
  );
  
  $doc = new DOMDocument();
  $doc->formatOutput = true;
  
  $r = $doc->createElement( "item" );
  $doc->appendChild( $r );
  
  foreach( $item as $list )
  {
  $b = $doc->createElement( "list" );
  
  $title = $doc->createElement( "title" );
  $title->appendChild(
  $doc->createTextNode( $list['title'] )
  );
  $b->appendChild( $title );
  
  $description = $doc->createElement( "description" );
  $description->appendChild(
  $doc->createTextNode( $list['description'] )
  );
  $b->appendChild( $description );
  
  $link = $doc->createElement( "link" );
  $link->appendChild(
  $doc->createTextNode( $list['link'] )
  );
  $b->appendChild( $link );
 
  $thumb = $doc->createElement( "thumb" );
  $thumb->appendChild(
  $doc->createTextNode( $list['thumb'] )
  );
  $b->appendChild( $thumb );
    
  $content = $doc->createElement( "content" );
  $content->appendChild(
  $doc->createTextNode( $list['content'] )
  );
  $b->appendChild( $content );
  
  
  $r->appendChild( $b );
  }
  
  echo $doc->saveXML();
  $doc->save("list.xml")
  ?>

thanks freshfitz but i think to solve this problem the php needs to delete a specific data the add a data in the place of the deleted one.
but i don't know how to do it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.