熟悉dom4j的朋友过来帮忙看看,如何删除这个属性值在线等谢谢了

时间:2008-06-12 08:11:50   来源:论坛整理  作者:  编辑:chinaitzhe
XML code





Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/



<?xml version="1.0" encoding="GBK"?>

<?eclipse version="3.0"?>



<plugin> 

  <extension point="org.eclipse.ui.actionSets"> 

    <actionSet id="com.obt.orion4.actionSet" label="Purview" visible="false"> 

      <menu id="Purview" label="Purview" path="Project/additions"> 

        <separator name="myGroup"/> 

      </menu>  

      <action class="com.obt.orion4.actions.UserAction" enablesFor=" " icon="icons/user.gif" id="com.obt.orion4.actions.UserAction" label="User" menubarPath="Project/Purview/myGroup"/>  

      <action class="com.obt.orion4.actions.GroupAction" enablesFor="1" icon="icons/group.gif" id="com.obt.orion4.actions.GroupAction" label="Group" menubarPath="Project/Purview/myGroup"/> 

    </actionSet> 

  </extension> 

</plugin> 




我要删除两个action的enablesFor属性,我的代码:
Java code





Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/





openXML();

    Element extensionEle;

    Element actionSetEle;

    Element root = this.document.getRootElement();

    extensionEle = root.element("extension");

    actionSetEle = extensionEle.element("actionSet");

    for (Iterator i = actionSetEle.elementIterator(); i.hasNext();) {

        Element action = (Element) i.next();

        for(Iterator ii=action.attributeIterator();ii.hasNext();){

            Attribute attribute =(Attribute)ii.next();

            while(attribute.getName().equals("enablesFor")){

                Attribute myattribute=action.attribute("enablesFor");

            //myattribute.setValue(myattribute.getValue().equals(" ")?null:" ");

            //System.out.println(myattribute.getValue());    

                action.remove(myattribute);

                }        

            }

        }

        saveXML();

    




这么删总是不成功,大家帮忙看看,应该怎么改,才能删除两个enablesFor属性.谢谢....
网友回复:
Java code





Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/





               for (Iterator i = actionSetEle.elementIterator(); i.hasNext();) {

            Element action = (Element) i.next();

            if ("action".equals(action.getName())) {

                Attribute attribute = action.attribute("enablesFor");

                action.remove(attribute);

            }

        }




网友回复:非常感谢您,可以了
关键字:熟悉,dom,朋友,过来,帮忙,看看,

文章评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面