我试图缩进我的XML文件,但我不能因为这个错误。 为什么会出现此问题?PHP DOMDocument:致命错误:调用未定义的方法DOMElement :: save()
这是我的代码:
<?php
$xmlstr = 'xmlfile.xml';
$sxe = new SimpleXMLElement($xmlstr, null, true);
$lastID = (int)$sxe->xpath("//tip[last()]/tipID")[0] + 1;
$tip = $sxe->addChild('tip');
$tip->addChild('tipID', $lastID);
$tip->addChild('tiptitle', 'Title:');
$sxe->asXML($xmlstr);
$xmlDom = dom_import_simplexml($sxe);
$xmlDom->formatOutput = true;
$xmlDom->save($xmlstr);
?>
我已经做了很多的研究,我无法找到答案。
@ splash58没有解决它不幸。错误保持不变,但使用saveXML而不是保存。 –