【www.gdgbn.com--php入门】
$doc = new domdocument("1.0");
// we want a nice output
$doc->formatoutput = true;
$root = $doc->createelement("book");
$root = $doc->appendchild($root);
$title = $doc->createelement("title");$title = $root->appendchild($title);
$text = $doc->createtextnode("this is the title");
$text = $title->appendchild($text);
echo "retrieving all the document: ";
echo $doc->savexml() . " ";
echo "retrieving only the title part: ";
echo $doc->savexml($title);