一、截取特定字符串
string backmsg="<response><Code>00123</Code><response>";
string[] sArray = backmsg.Split(new string[] { "<Code>", "</Code>" }, StringSplitOptions.RemoveEmptyEntries);
string errcode = sArray[1];
//此时errcode就是00123
二、截取HTML字符串为摘要显示
//先清除html再截取
string s=striphtml(原内容字符串).subString(0,100);
//清除html
public static string striphtml(string strhtml)
{
string stroutput = strhtml;
Regex regex = new Regex(@"<[^>]+>|</[^>]+>");
stroutput = regex.Replace(stroutput, "");
return stroutput;
}
//此时s即为摘要字符串