String startTag = "<sessionid>";
String endTag = "</sessionid>";
if (startTag.equalsIgnoreCase("<sessionid>") &&
endTag.equalsIgnoreCase("</sessionid>"))
{
int startLocation = strResponse.indexOf(startTag);
int endLocation = strResponse.indexOf(endTag);
Log.i("StartLocation", ""+startLocation);
Log.i("EndLocation", ""+endLocation);
String session_id = strResponse.substring(startLocation, endLocation);
ConstantData.session_id =session_id;
Log.i("SessionId", ""+session_id);
}
我得到session_id = <sessionid>32423jhoijhoijh
;所以我想刪除<sessionid>
。任何幫助將不勝感激。從字符串中刪除字符串
嘗試String session_id = strResponse.substring(startLocation + 11,endLocation);這裏是11的長度是 –
mudit
2011-04-04 12:44:18
確切的重複[如何刪除一部分字符串?](http://stackoverflow.com/questions/5538271/how-can-i-remove-a-part-of-a -string) – 2011-04-04 12:52:43
請將答案標誌授予爲您提供合適解決方案的人員。 – JJD 2012-11-11 16:00:54