$dom = new domDocument("1.0","ISO-8859-1");
$dom->formatOutput = 1;
$root = $dom->createElement('forum');
$root->setAttribute('uri', 'http://fudforum.org/index.php');
$branch = $dom->createElement('item');
$branch->setAttribute('id', '1');
$leaf = $dom->createElement('title');
$leaf->appendChild($dom->createTextNode('First Post!!!'));
$branch->appendChild($leaf);
$leaf = $dom->createElement('link');
$leaf->appendChild($dom->createTextNode('http://fudforum.org/index.php/m/1'));
$branch->appendChild($leaf);
$leaf = $dom->createElement('description');
$leaf->appendChild($dom->createTextNode('1st message in the forum.'));
$branch->appendChild($leaf);
$root->appendChild($branch);
$branch = $dom->createElement('item');
$branch->setAttribute('id', '2');
$leaf = $dom->createElement('title');
$leaf->appendChild($dom->createTextNode('Re: First Post!!!'));
$branch->appendChild($leaf);
$leaf = $dom->createElement('link');
$leaf->appendChild($dom->createTextNode('http://fudforum.org/index.php/m/1'));
$branch->appendChild($leaf);
$leaf = $dom->createElement('description');
$leaf->appendChild($dom->createTextNode('Almost like Slashdot.'));
$branch->appendChild($leaf);
$root->appendChild($branch);
$dom->appendChild($root);
echo $dom->saveXML();
output:
http://fudforum.org/index.php/m/1 1st message in the forum. http://fudforum.org/index.php/m/1 Almost like Slashdot.
Why im I not getting the id and the title in the output.