首先得选择xml解析器,用jdom最方便:
以下是利用jdom得例子:
Element1.setAttribute( new Attribute("att1", yourString) );
Element1.addContent( new Element("elem2").setText( yourString ) );
以下是利用jdom得例子:
Element1.setAttribute( new Attribute("att1", yourString) );
Element1.addContent( new Element("elem2").setText( yourString ) );
我的意思是在已有XML文件的里把一个类中某个JAVA变量的值