<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"和消息“层次请求错误"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  PHP Upload File Validation(PHP 上传文件验证)
                  PHP Error - Uploading a file(PHP 错误 - 上传文件)
                  How can I write tests for file upload in PHP?(如何在 PHP 中编写文件上传测试?)
                  php resizing image on upload rotates the image when i don#39;t want it to(php在上传时调整图像大小会在我不想要它时旋转图像)
                  How to send additional data using PLupload?(如何使用 PLupload 发送附加数据?)
                  change button text in js/ajax after mp4 =gt;mp3 conversion in php(在 php 中的 mp4 =gt;mp3 转换后更改 js/ajax 中的按钮文本)

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