<bdo id='RLZhG'></bdo><ul id='RLZhG'></ul>
<tfoot id='RLZhG'></tfoot>
  • <i id='RLZhG'><tr id='RLZhG'><dt id='RLZhG'><q id='RLZhG'><span id='RLZhG'><b id='RLZhG'><form id='RLZhG'><ins id='RLZhG'></ins><ul id='RLZhG'></ul><sub id='RLZhG'></sub></form><legend id='RLZhG'></legend><bdo id='RLZhG'><pre id='RLZhG'><center id='RLZhG'></center></pre></bdo></b><th id='RLZhG'></th></span></q></dt></tr></i><div id='RLZhG'><tfoot id='RLZhG'></tfoot><dl id='RLZhG'><fieldset id='RLZhG'></fieldset></dl></div>

    <small id='RLZhG'></small><noframes id='RLZhG'>

    1. <legend id='RLZhG'><style id='RLZhG'><dir id='RLZhG'><q id='RLZhG'></q></dir></style></legend>

      1. 未捕获的异常“DOMException"和消息“层次请求错误"

        Uncaught exception #39;DOMException#39; with message #39;Hierarchy Request Error#39;(未捕获的异常“DOMException和消息“层次请求错误)

          1. <small id='a80n8'></small><noframes id='a80n8'>

            <tfoot id='a80n8'></tfoot>

            <i id='a80n8'><tr id='a80n8'><dt id='a80n8'><q id='a80n8'><span id='a80n8'><b id='a80n8'><form id='a80n8'><ins id='a80n8'></ins><ul id='a80n8'></ul><sub id='a80n8'></sub></form><legend id='a80n8'></legend><bdo id='a80n8'><pre id='a80n8'><center id='a80n8'></center></pre></bdo></b><th id='a80n8'></th></span></q></dt></tr></i><div id='a80n8'><tfoot id='a80n8'></tfoot><dl id='a80n8'><fieldset id='a80n8'></fieldset></dl></div>
              • <bdo id='a80n8'></bdo><ul id='a80n8'></ul>
                    <tbody id='a80n8'></tbody>
                • <legend id='a80n8'><style id='a80n8'><dir id='a80n8'><q id='a80n8'></q></dir></style></legend>
                  本文介绍了未捕获的异常“DOMException"和消息“层次请求错误"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在将子节点替换或添加到节点时出错.

                  I'm getting error while replacing or adding a child into a node.

                  必填:

                  我想把这个改成..

                  <?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>
                  

                  错误是

                  致命错误:未捕获的异常DOMException"和消息层次请求错误"

                  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);
                      }
                  }
                  

                  推荐答案

                  PHP 中的 Hierarchy Request Error with DOMDocument 表示您正在尝试将节点移动到本身.将其与下图中的蛇进行比较:

                  The error Hierarchy Request Error with DOMDocument in PHP means that you are trying to move a node into itself. Compare this with the snake in the following picture:

                  与您的节点类似.您将节点移动到自身中.这意味着,当您想用段落替换人时,该人已经是该段落的子项.

                  Similar this is with your node. You move the node into itself. That means, the moment you want to replace the person with the paragraph, the person is already a children of the paragraph.

                  appendChild() 方法已经有效地将人移出 DOM 树,它不再是一部分:

                  The appendChild() method effectively already moves the person out of the DOM tree, it is not part any longer:

                  $para = $doc->createElement("p");
                  $para->setAttribute('attr', 'value');
                  $para->appendChild($person);
                  
                  <?xml version="1.0"?>
                  <contacts>
                    <person>Adam</person>
                  
                    <person>John</person>
                    <person>Thomas</person>
                  </contacts>
                  

                  伊娃已经走了.它的 parentNode 已经是段落了.

                  Eva is already gone. Its parentNode is the paragraph already.

                  因此,您首先要替换然后附加孩子:

                  So Instead you first want to replace and then append the child:

                  $para = $doc->createElement("p");
                  $para->setAttribute('attr', 'value');
                  $person = $person->parentNode->replaceChild($para, $person);
                  $para->appendChild($person);
                  
                  <?xml version="1.0"?>
                  <contacts>
                    <person>Adam</person>
                    <p attr="value"><person>Eva</person></p>
                    <person>John</person>
                    <person>Thomas</person>
                  </contacts>
                  

                  现在一切都很好.

                  这篇关于未捕获的异常“DOMException"和消息“层次请求错误"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <bdo id='CLkvg'></bdo><ul id='CLkvg'></ul>

                      <tbody id='CLkvg'></tbody>

                    1. <small id='CLkvg'></small><noframes id='CLkvg'>

                      <legend id='CLkvg'><style id='CLkvg'><dir id='CLkvg'><q id='CLkvg'></q></dir></style></legend>
                    2. <i id='CLkvg'><tr id='CLkvg'><dt id='CLkvg'><q id='CLkvg'><span id='CLkvg'><b id='CLkvg'><form id='CLkvg'><ins id='CLkvg'></ins><ul id='CLkvg'></ul><sub id='CLkvg'></sub></form><legend id='CLkvg'></legend><bdo id='CLkvg'><pre id='CLkvg'><center id='CLkvg'></center></pre></bdo></b><th id='CLkvg'></th></span></q></dt></tr></i><div id='CLkvg'><tfoot id='CLkvg'></tfoot><dl id='CLkvg'><fieldset id='CLkvg'></fieldset></dl></div>

                        <tfoot id='CLkvg'></tfoot>