我試圖縮進我的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而不是保存。 –