LINQ: How to get the last XML Child Node?

  • Thread starter Thread starter Open Galaxy
  • Start date Start date
O

Open Galaxy

Guest
I have an XML that looks like the xml below:
How do I get the last node?

I do not want to pass an ID but rather just get the element that is last for color.
I am doing something like this but it relies on the ID:


List<XElement> node = (from el in exampleParent.Descendants("red")
where el.Element("id").Value == "3"
select ed).ToList();


<color>

<red id="1">
</red>

<red id="2">
</red>

<red id="3">
</red>

</color>

Continue reading...
 
Back
Top