提取含有国家字符串。
<state>国家</state>
string result;
if (Extract(line, result, "<state>", "</state>"))
cout << result << endl;
bool Extract(string src, string &result, const char * szStart, const char *szEnd)
{
int strlength = strlen(szStart);
string::size_type start = src.find(szStart);
if (start != string::npos)
{
string::size_type end = src.find(szEnd);
if (end != string::npos)
{
result = src.substr(start + strlength, end - start - strlength);
return true;
}
else
return false;
}
else
return false;
}