向Elment中添加元素,用appendChild()方法时碰到的问题 Element temp=(Element)content.cloneNode(true);cloneNode()方法只能返回Node对象,可能java.lang.ClassCastException错出在此句 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我想应该不是这个问题,因为意外是出在service_attacheds.appendChild(temp)这一句。 Element temp=(Element)content.cloneNode(true); service_attacheds.appendChild(temp);你的强制类型转换多余cloneNode返回的是Node接口的对象,而appendChild的参数也是Node类型的 Element register=doc1.getDocumentElement();NodeList list=register.getElementsByTagName("service_attached");Element content=(Element)list.item(0);Element rootElmt=doc2.getDocumentElement();NodeList serviceatts=rootElmt.getElementsByTagName("service_attacheds");Element service_attacheds=(Element)serviceatts.item(0);//你这样试一下//Element temp=(Element)content.cloneNode(true);Node temp = doc2.importNode(content, true);service_attacheds.appendChild(temp); JBoss jsp 里两个resultset同时使用 Hibernate的Query用法 求助:tomcat部署到服务器无法访问 SSH 登陆例子 图片按钮提交 每次都生成的2遍sql语句 为什么啊? 刚刚用struts写了一个程序,但是error的时候jsp显示不出来 如何理解Servelt请求对象和响应对象 报告学习情况 如何在struts中的action forward到另一个action java习题 赐教 交换代码用于学习! 请各位推荐几本J2EE的书?
service_attacheds.appendChild(temp);
你的强制类型转换多余
cloneNode返回的是Node接口的对象,而appendChild的参数也是Node类型的
NodeList list=register.getElementsByTagName("service_attached");
Element content=(Element)list.item(0);
Element rootElmt=doc2.getDocumentElement();
NodeList serviceatts=rootElmt.getElementsByTagName("service_attacheds");
Element service_attacheds=(Element)serviceatts.item(0);
//你这样试一下
//Element temp=(Element)content.cloneNode(true);
Node temp = doc2.importNode(content, true);
service_attacheds.appendChild(temp);