Team;
How are you doing? Im breaking my head trying to do this that seems simple but I can't figure it out... Suppose I have this XML as a string:
<calles>
<calle>
<nombre>CALLAO AV.</nombre>
<altura>1500</altura>
<longitud>-58.3918617027</longitud>
<latitud>-34.5916734896</latitud>
<barrio>Recoleta</barrio>
</calle>
</calles>
And and have this Type I created to map that XML:
public class Ubicacion
{
public string Latitud { get; set; }
public string Longitud { get; set; }
public string Nombre { get; set; }
public string Altura { get; set; }
public string Barrio { get; set; }
public Ubicacion() { }
}
I need to take that XML file and create an object with those values...
Does somebody know a quick way to do it? with C#? I have been trying this but is not working at all...
XElement dir = XElement.Parse(text);
Ubicacion informacion = from d in dir.Elements("calle").
select new Ubicacion
{
Longitud = d.Element("longitud").Value,
Latitud = d.Element("latitud").Value,
Altura = d.Element("altura").Value,
Nombre = d.Element("nombre").Value,
Barrio = d.Element("barrio").Value,
};
return informacion.Cast<Ubicacion>();
}
Any ideas?
Thanks!!!