在將節點替換或添加到節點時出現錯誤。帶有消息「層次結構請求錯誤」的未捕獲異常'DOMException'
需要的是:
我想改變這..
<?xml version="1.0"?>
<contacts>
<person>Adam</person>
<person>Eva</person>
<person>John</person>
<person>Thomas</person>
</contacts>
這樣
<?xml version="1.0"?>
<contacts>
<person>Adam</person>
<p>
<person>Eva</person>
</p>
<person>John</person>
<person>Thomas</person>
</contacts>
誤差
Fatal error: Uncaught exception 'DOMException' with message 'Hierarchy Request Error'
我的代碼是
function changeTagName($changeble) {
for ($index = 0; $index < count($changeble); $index++) {
$new = $xmlDoc->createElement("p");
$new ->setAttribute("channel", "wp.com");
$new ->appendChild($changeble[$index]);
$old = $changeble[$index];
$result = $old->parentNode->replaceChild($new , $old);
}
}
你可以看到xml需求的問題詳細信息... – 2013-05-02 17:51:06
當我嘗試使用replaceChild時出現錯誤說'Hierarchy Request Error'我不明白我在做什麼錯誤 – 2013-05-02 17:55:49
我只想要一個節點是需要的被包含在p標籤多數民衆贊成在它。 – 2013-05-02 17:57:21