日期:2014-05-17 浏览次数:20656 次
<users> <user name="xiaoming" pwd="123">boy</user> <user name="xiaohong" pwd="456">girl</user> </users>
public String getValueFrmXML(String field)throws BtirException { String ret =""; if(null != xml && xml.trim().length()==0) throw new BtirException( BtirException.INVALID_DATA); String cXml = xml; int idx = cXml.indexOf(field+"/"); if(idx>-1){ return ""; } if("SessionBody>".equals(field)){ cXml = cXml.replaceAll("\\s", ""); idx = cXml.indexOf(field); }else{ idx = cXml.indexOf(field+">"); } if(idx >-1){ cXml = cXml.substring((idx+field.length()+1)); int odx = cXml.indexOf("<"); if(odx>-1){ ret = cXml.substring(0,odx); } } return ret; }