子供をノードに置き換えたり追加したりする際にエラーが発生します。「階層リクエストエラー」というメッセージがあるキャッチされない例外「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要求を見ることができます... –
私がreplaceChildを使用しようとすると、「階層要求エラー」というエラーが表示されます。私が間違っているものがわからない –
ただノードが必要です。それはpタグで囲まれています。 –