例如:
<ArrayOfString xmlns:xsi="#" xmlns:xsd="#" xmlns="#">
<string>1</string>
<string>2</string>
<string>3</string>
</ArrayOfString>
public async Task<WeatherContext> Weather(string city) { var client = new RestClient(_config["Weatherurl"]+ city); client.Timeout = -1; var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); string[] s = new string[3];//声明string数组存放返回结果 string bl = ""; string z = response.Content; int k = 0; bool b = true; for (int i = 0; i < z.Length-8; i++) { if (b) { bl = z.Substring(i, 8); } if (bl.Equals("<string>")) { if (z.Substring(i+8,1)!="<") { b = false; s[k] += z.Substring(i + 8, 1); } else { b = true; k++; i += 8; } } } WeatherContext weather = new WeatherContext { 1 = s[0], 2 = s[1], 3 = s[2], }; return weather; }