如何添加XML树上节点的属性?? 先用当前的Document对象使用createAttribute(String)创建一个属性节点然后使用父节点的setAttributeNode()将新建的属性加到节点中。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 // 解析Document,得到document,过程略Document document;Node parent;Attr newAttr = document.createAttribute("NewAttribute");parent.setAttributeNode(newAttr); 那属性值呢?NewAttribute是属性名吧? 应该是这样的:Element node = document.createElement("node");node.setAttribute("attrname","attrvalue");谢谢二位的指点! 大家看看为什么事物不起作用呢?在线等待 treeitem为什么添加不了单击事件? 学 J2EE 要先学什么 熟悉ExtJS进来帮个忙最近自己想整合ExtJs和Struts做一个小型的管理系统。遇到点问题卡住了 JFreeChart数据在鼠标放上去才显示? Hibnate级联删除 只能删除一方 struts + hibernate+Spring 问题 急 北京国际商务学院一年制得文凭真得假得 我是新手,刚学ejb,有个问题困扰我几天了,请大家帮帮忙!! 400分求面试题 可否介绍一下关于EPR、CRM这类软件用java实现的书,还有就是j2ee方面的好书 EJB访问一个自定义类出错!奇怪!!
Document document;
Node parent;
Attr newAttr = document.createAttribute("NewAttribute");
parent.setAttributeNode(newAttr);
Element node = document.createElement("node");
node.setAttribute("attrname","attrvalue");
谢谢二位的指点!