I have an XML like this
<Node Name="segment_@85D819AE">
<Node Name="segment_body37sub0">
<Node Name="face_82C1EB14_4"/>
</Node>
<Node Name="segment_body37sub1">
<Node Name="face_82C1ED90_5"/>
</Node>
<Node Name="segment_body37sub2">
<Node Name="face_82C1EF38_6"/>
</Node>
</Node>
I want to get on the following from the above XML.
face_82C1EB14_4
face_82C1ED90_5
face_82C1EF38_6
Basically all the Last elements in to a List
I am using c# Frame work 4.0.
It sounds like you're just trying to find the names of all elements with no child elements, then project from each of those elements to the Name
attribute value:
var names = doc.Descendants() // Or Descendants("Node")
.Where(x => !x.Elements().Any())
.Select(x => x.Attribute("Name").Value);
See more on this question at Stackoverflow