I have a XML feed loaded in an XElement.
The structure is
<root>
<post></post>
<post></post>
<post></post>
<post></post>
.
.
.
.
<post></post>
</root>
I want to directly get the value of the Last post. How I do that using XElement in C#.
Thanks.
Try this:
If you aren't sure there'll be any, you could also use LastOrDefault(). If there might be other elements besides within the , there's an overload of Descendants that will let you find just the posts you're looking for.
Try this
Or try this to get XElement:
You can use
LastNode
property on root element: