<?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 "Saving all the document:\n";
echo $doc->saveXML() . "\n";echo "Saving only the title part:\n";
echo $doc->saveXML($title);?>echo 出来只显示
Saving all the document: Saving only the title part:
xml的内容无法显示出来!
// 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 "Saving all the document:\n";
echo $doc->saveXML() . "\n";echo "Saving only the title part:\n";
echo $doc->saveXML($title);?>echo 出来只显示
Saving all the document: Saving only the title part:
xml的内容无法显示出来!
解决方案 »
- 新人问个关于运算符的问题
- 请问如何判断一个IP是否为代理服务器?
- Drupal中如何显示最新发布的新闻等等例如下面
- 一个麻烦的问题:如何判断XML文件的一个节点下是否有<![CDATA[...]]>
- 急!!局域网的其他电脑不能访问服务器的Apache
- MYSQL错误:Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (gbk_chinese_ci,COERCIBLE) for operation '='
- 高手快来帮忙啊,急急急急急急急急急急急急急急急急急
- 问一个很弱的问题
- getimagesize函数的问题!
- php -str_replace无法遍历替换
- LINUX的7777是指什么??
- 向MYSQL中插入数据不成功
<?xml version="1.0"?>
<book>
<title>This is the title</title>
</book>Saving only the title part:
<title>This is the title</title>不知你期望的是什么
Saving all the document:
<?xml version="1.0"?>
<book>
<title>This is the title</title>
</book>
Saving only the title part:
<title>This is the title</title>
echo "Saving all the document:\n";
$a= $doc->saveXML() ;
echo $a. "\n";echo "Saving only the title part:\n";
$b= $doc->saveXML($title);
echo $b;
1、整个程序只有一次输出 echo $doc->saveXML();
2、必要时(视浏览器而定)需加类型声明的头 header("content-type:text/xml");