Possible Duplicate:
How is possible add child to the specific node
how i can add nodes to xml file like that:
<users>
<user uid="1" name="Alvin" email="example@example.com"/>
</users>
example php:
$xml_file = "example.xml";
// WRITING TO XML FILE
if(!empty($_GET['add'])){
$u_name = stripslashes($_POST['u_name']);
$u_email = stripslashes($_POST['u_email']);
// Generate new (appended) ID
foreach($xml as $user){
$last_id = $user->uid;
}
$id = $last_id+1;
// Add node
$x = $xml->addChild("user");
$x->addChild("uid",$id);
$x->addChild("name",$u_name);
$x->addChild("email",$u_email);
$xml->asXML($xml_file);
}
thank you for any help and/or advise