XML文件,我有如下以供製作以XML格式返回數據的其餘請求方法 -從創建REST響應
public void Test()
{
string requestUri = string.Empty;
try
{
requestUri = String.Format("uri/{0}?locales={1}", "test", "en-gb");
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(requestUri);
HttpResponseMessage response = client.GetAsync(requestUri).Result;
if (response.IsSuccessStatusCode)
{
string content = response.Content.ReadAsStringAsync().Result;
// Want to create xml file here
this.WriteToFile(content);
}
}
catch (Exception)
{
throw;
}
}
如何創建從我從API得到的迴應一個xml文件?
response.ContentType =「text/xml」; –