import org.jdom.* ; import org.jdom.output.* ; import org.jdom.input.* ; import java.io.* ; import java.util.*; /* 作者:雨伞 时间:2004/12/28 */ public class javaxml { public string path=null; public string xmlfilename=null; public saxbuilder sax=null; public document doc=null; public element root=null; public list xlist=null; public element e=null; public element value=null;
public string gettest(){ return new string("haha"); } public javaxml(){
}
public string init(){
inputstream is = getclass().getresourceasstream("global.properties"); properties dbprops = new properties(); try { dbprops.load( is ) ; } catch ( exception e ) { return ("error file"); } this.path=dbprops.getproperty("xmlpath"); return ("ok"); }
public void get(int child){ this.e=(element)xlist.get(child); } public string getvalue(string name){ this.value=e.getchild(name); return this.value.gettext(); } public void setvalue(string name,string value)throws exception{ this.value=e.getchild(name); this.value.settext(value); xmloutputter xmlout=new xmloutputter(); xmlout.output(doc,new fileoutputstream(path+xmlfilename)); }