0 0

org.w3c.dom.DOMException:WRONG_DOCUMENT_ERR 5

org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.

Document doc = DocumentBuilderFactory.newInstance()
                           .newDocumentBuilder()
                           .parse(new ByteArrayInputStream(out.toByteArray()));

SOAPBody body = msg.getSOAPBody();
                   Node port = body.getChildNodes().item(0);
           
port.appendChild(doc.getFirstChild().getFirstChild());

appendChild,添加节点的时候提示A node is used in a different document than the one that created it.

请问要怎么办?谢谢!
SOA 
2013年7月14日 19:12

2个答案 按时间排序 按投票排序

0 0

要想把 b.xml中的node nb插入到 a.xml的节点na中,只有这样:
na.importNode(nb,true);

2014年10月16日 15:20
0 0

port的创建者不是doc,所以两个document对象的元素是不能互相添加的,你可以使用cloneNode方法,将doc对象的节点克隆一个给port。

2013年7月15日 08:09

相关推荐

Global site tag (gtag.js) - Google Analytics