I need some help using Linq to xml, I’ve been reading online articles but still no luck, can anyone please help me out?
I just need to read an xml file, the problem I’m having is that it has lots of sub levels and I haven’t been able to access them.
<Dias>
<Dia id="0">
<Restricciones>
<Restriccion tipo="Ambiental" horaInicio="6" horaFin="10">
<Placas>
<Placa>4</Placa>
</Placas>
</Restriccion>
</Restricciones>
</Dia>
</Dias>
My current code is:
var dia = (int)DateTime.Now.DayOfWeek;
var xElement = XElement.Load("Bogota.xml");
var d = (from dias in xElement.Descendants("Dia")
where dias.Attribute("id").Value == dia.ToString()
select dias).First();
var rest = (from r in d.Descendants("Restricciones")
select r);
But I’ve tried several variations, but no luck so far
Can someone help?
This should work