douxiong0668 2013-10-04 06:51 采纳率: 100%
浏览 37
已采纳

PHP DOMDocument insertBefore抛出“未找到错误”

I have a DOMDocument and I am trying to insert an node before an other.

$doc = $parent->ownerDocument;
$xref_node = $doc->importNode($xref, true);
$ref = $doc->importNode($ref, true);
$parent->insertBefore($xref_node, $ref_node);

$parent, $xref and $ref are DOMElements.

Somehow, this is generating an "Not Found Error" on the line where I am using insertBefore.

Any idea why? I am using here the ownerDocument of the $parent, importing the two nodes $xref and $ref in this document and then try to use the insert before, on nodes from the same document.

Thank you in advance.

  • 写回答

1条回答 默认 最新

  • duanhuang4841 2013-10-07 00:51
    关注

    There is a bug: $ref = should be $ref_node =

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部