I made a call through my web api and put it in a class. How do I display the values?
xml:
<result>
<resourceName>activity</resourceName>
<size>1</size>
<entries>
<entry id="1802274" link="/activity/1802274.xml"/>
</entries>
</result>
I get the xml:
public class PegaVisita
{
HttpClient client;
Uri usuarioUri;
public async System.Threading.Tasks.Task GeraLocalAsync()
{
try
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://api.umov.me");
HttpResponseMessage response = client.GetAsync("CenterWeb/api/meutoken/activity.xml?description=Cancelar&Coletas").Result;
string tarefa = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
var buffer = Encoding.UTF8.GetBytes(tarefa);
using (var stream = new MemoryStream(buffer))
{
var serializer = new XmlSerializer(typeof(Result));
var Teste = (Result)serializer.Deserialize(stream);
}
usuarioUri = response.Headers.Location;
}
}
}
catch (Exception ex)
{
Console.Write("Erro ao cadastrar os locais");
Console.Write("Error : " + ex.Message);
}
}
}
class that receives xml
namespace WsCliMotoristas
{
[Serializable]
[XmlRoot("result"), XmlType("rstult")]
public class Result
{
[XmlElement("resourceName")]
public string resourceName { get; set; }
[XmlElement("size")]
public string size { get; set; }
}
}
I do not fall into any exception, you're doing everything right. I just need to know how to retrieve the values of the classes, display them or save them in the database, for example