<?php
$dom 
= new domDocument('1.0');
$dom->load(dirname(__FILE__) . "/thedata.xml");

$new_item $dom->createElement('item');
$new_item->setAttribute("id"1234); // set attribute id for new item
foreach (array('title''link''description') as $v) {
    
$node $dom->createElement($v);
    
$node->appendChild($dom->createTextNode($v));
    
$new_item->appendChild($node);
}
// append entry to existing forum entries
$dom->documentElement->appendChild($new_item);
$xml $dom->saveXML();

echo 
nl2br(htmlspecialchars(str_replace('><'">\n<"$xml)));
?>
Output
<?xml version="1.0"?>
<forum uri="http://fud.prohost.org/forum/index.php">

<item id="10084">
<title>Binary Protocols vs XML</title>
<link>http://fud.prohost.org/forum/index.php/m/10084</link>
<description>Why does everyone insist on using XML?</description>
</item>

<item id="10149">
<title>How do I post messages?</title>
<link>http://fud.prohost.org/forum/index.php/m/10149</link>
<description>I can post messages, help!</description>
</item>

<item id="1234">
<title>title</title>
<link>link</link>
<description>description</description>
</item>
</forum>