我想在不使用<br/>
的情况下在新行上打印xml文档的每个元素。使用 n打印xml节点时出错 n
这是我正在使用的代码,但它跳过了“\ n”。请帮助
<?php
$xmlstr= '<Address><to>James</to><from>Jani</from><heading>Reminder</heading><body>Please check your mail.</body></Address>' ;
$xml = simplexml_load_string($xmlstr);
echo $xml->getName() . "\n";
foreach($xml->children() as $child)
{
echo $child->getName() . ": " . $child . "\n";
}
?>
所需的输出:
Address to: James from: Jani heading: Reminder body: Please check your mail.
如果你是在找这网页浏览器,它会跳过新行,除非你不发送内容类型文本/纯文本标题 – 2012-03-12 10:03:19
所以,我做的是正确的?除了浏览器不显示它正确吗?我如何发送内容类型文本/普通标题 – 2012-03-12 10:08:20