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

热门教程

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

时间:2022-06-24 20:53:50 编辑:袖梨 来源:一聚教程网

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

热门栏目