İşte kod:
<?php
$dom = new DOMDocument('1.0', 'utf-8');
$rss = $dom->createElement('rss');
$dom->appendChild($rss);
$version = $dom->createAttribute('version');
$rss->appendChild($version);
$value = $dom->createTextNode('2.0');
$version->appendChild($value);
$xmlns_wp = $dom->createAttribute('xmlns:wp');
$rss->appendChild($xmlns_wp);
$value = $dom->createTextNode('http://url.com');
$xmlns_wp->appendChild($value);
$xmlns_dc = $dom->createAttribute('xmlns:dc');
$rss->appendChild($xmlns_dc);
$value = $dom->createTextNode('http://url2.com');
$xmlns_dc->appendChild($value);
$channel = $dom->createElement('channel');
$rss->appendChild($channel);
$items = $dom->createElement('items');
$channel->appendChild($items);
$sometags = $dom->createElement('sometags', '');
$items->appendChild($sometags);
$wp_status = $dom->createElement('wp:status', '');
$items->appendChild($wp_status);
echo $dom->saveXML();
?>
Bu çıkışlar:
<?xml version="1.0" encoding="utf-8"?>
<rss
version="2.0"
xmlns:wp="http://url.com"
xmlns:dc="http://url2.com"
>
<channel>
<items>
<sometags></sometags>
<wp:status></wp:status>
</items>
</channel>
</rss>
Fore fazla yardım: http://us2.php.net/manual/en/book.dom.php