$sitemap .= " " . '<orders>' . "\n" .
"\t" . '<idKlant>' . $id. '</idKlant>' .
"\n\t" . '<emptyfield></emptyfield>' .
"\n\t" . '<date>' . $verzenddatum . '</date>' . //remaining to get
"\n " . '</orders>' . "\n";
为了生成 XMl,我使用下面的代码
$xmlobj = new SimpleXMLElement($sitemap);
$xmlobj->asXML("orders.xml");
的输出orders.xml
<orders>
<idKlant>12</idKlant>
<emptyfield/>
<date>30-12-2012</date>
</orders>
我想要的是:对于空 xml 字段也应该有打开和关闭标签
<orders>
<idKlant>12</idKlant>
<emptyfield></emptyfield>
<date>30-12-2012</date>
</orders>
可能吗?或者我应该添加黑色空间吗?