<?php
$xml= new SimpleXMLElement('<root></root>');
$xml->father['name']= 'Fathers name'; // creates automatically a father tag with attribute name
$son= $xml->father->addChild('son'); // uses the first father tag
$son['name']= 'first son';
$otherSon= $xml->father->addChild('son'); // uses the first father tag but now, in a second son tag
$otherSon['name']= 'second son'; //echo htmlentities($xml->asXML());
echo $xml->asXML();?>
我用上边程序新建xml文件并打印,但结果挤在一块没法肉眼看清
<?xml version="1.0"?>
<root><father name="Fathers name"><son name="first son"/><son name="second son"/></father></root>
如何才能使结果缩进可读呢?
$xml= new SimpleXMLElement('<root></root>');
$xml->father['name']= 'Fathers name'; // creates automatically a father tag with attribute name
$son= $xml->father->addChild('son'); // uses the first father tag
$son['name']= 'first son';
$otherSon= $xml->father->addChild('son'); // uses the first father tag but now, in a second son tag
$otherSon['name']= 'second son'; //echo htmlentities($xml->asXML());
echo $xml->asXML();?>
我用上边程序新建xml文件并打印,但结果挤在一块没法肉眼看清
<?xml version="1.0"?>
<root><father name="Fathers name"><son name="first son"/><son name="second son"/></father></root>
如何才能使结果缩进可读呢?
解决方案 »
- php与mysql的配置问题
- 【求助】关于Apache+PHP+MySql的初学疑惑
- 我用PHP Editor看着书编辑了一个PHP的代码,然后保存了以php为扩展名的文件,我要问的是:怎么运行这个文件啊??
- 如何获取发帖数?
- 高分求,我的Apache2设置问题,只能建立一个虚拟路径www.opms.com,再建一个www.test.com就不行,请高手指教一下
- 查找关于php的教学视频
- 专家们帮我看看这个文件写的有问题没?多谢帮忙!
- PHP图形处理,乱码问题。不是编码问题
- phpnuke是干嘛用的???
- 帮一下忙好吗??应该有的挑战性的哦!!
- php代码启动mysql后,如何往下运行?
- 请大哥们指教下
echo str_replace('>', ">\n", $xml->asXML());