は私がcreated.I私はノードが1よりも、別のドキュメントで使用されているエラー WRONG_DOCUMENT_ERR:
実行時間を取得していますdomノードを新しいノードに置き換える方法は?
String messageBody=" <imgGroup><img src="src" width="width" height="height" alt="alt" type="type" orient="orient"/></imgGroup>"
File file=new File("doc.xml");
DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
doc = docBuilder.parse(file);
Element node = DocumentBuilderFactory
.newInstance()
.newDocumentBuilder()
.parse(new ByteArrayInputStream(messageBody.getBytes()))
.getDocumentElement();
System.out.println(node.getClass());
doc.getDocumentElement().replaceChild((Node)node, doc.getDocumentElement().getFirstChild());
}catch(Exception e){
e.printStackTrace();
}
としてこれを実装しています持っている新しいノードを既存のDOMノードを交換したいですそれを作成しました。
どのように異なる方法で行うことができますか?
ありがとうございます。 – ravitech