Create a file named "phpdom.php" within www/test/ajax. Enter following code:
<?php
header('Content-type: text/xml');
$dom = new DOMDocument();
$datas = $dom->createElement('datas');
$dom->appendChild($datas);
$id = $dom->createElement('id');
$idText = $dom->createTextNode('1');
$id->appendChild($idText);
$title = $dom->createElement('title');
$titleText = $dom->createTextNode('PHP Undercover');
$title->appendChild($titleText);
$author = $dom->createElement('author');
$authorText = $dom->createTextNode('Wiwit');
$author->appendChild($authorText);
$book = $dom->createElement('book');
$book->appendChild($id);
$book->appendChild($title);
$book->appendChild($author);
$datas->appendChild($book);
$xmlString = $dom->saveXML();
echo $xmlString;
?>
Point your browser to http://localhost/test/ajax/phpdom.php. You will get like: