Hi Friends!
i m getting some problem while writing data to XML file... in fact i want to add new child to my XML file and i did it. but problem is that i want to add this new child at the end of my xml but before the root (</Webmail>) tag. but when i write data to my file it writes another root tag which currupt my XML File 🙁 ...
below is the Code how i m writing...
$file = "filename.xml";
if (!$dom = domxml_open_file($file)) {
echo "Error while parsing the document\n";
exit;
}
$root = $dom->root();
$member = $root->new_child('mail','');
$member->new_child('id',312);
$member->new_child('to',"sdfjhghg@hotmail.com");
$member->new_child('from',"sdfsadfsadfsdaf");
$member->new_child('cc',"sdafsadf@dsfasdfsdaf");
//$member->new_child('bcc',$bcc);
$member->new_child('subject',"Manual Subject");
$member->new_child('date',"Manual Date");
$member->new_child('body',"Manual Body");
$fp = @fopen($file,'a');
if(!$fp) {
die('Error cannot create XML file');
}
fputs($fp,$dom->dumpmem());
fclose($fp);
and here is my XML file
<?xml version="1.0"?>
<Webmail>
<mail>
<id>1</id>
<to>name@servername.com</to>
<from>name@servername.com</from>
<cc>name@servername.com</cc>
<subject>HTML TEMPLATE</subject>
<date>Thu, 16 Jun 2005 17:14:52 +0500</date>
<body><html>
<head>
<title>Untitled Document</title>
<meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Diso-8859-1">
</head>

<body>
<img src=3D"http://static.php.net/www.php.net/images/php.gif">
</body>
</html></body>
</mail>
</Webmail>
Please help me...
Thanx in advance...
IFFY