一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

简单入门级php 生成xml文档代码

时间:2010-06-18 编辑:简简单单 来源:一聚教程网

$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);

热门栏目