I have some wonky XML I’m trying to read values from.
<text>
<term>a</term>
<line>
<elm>data here</elm>
</line>
<term>b</term>
<line>
<elm>data here</elm>
</line>
<term>c</term>
<line>
<elm>data here</elm>
</line>
</text>
I only have access to the the 3 line elements at this point.
As I loop over each line, for the first line I want to find the element term that happens to have “a” as a value since it’s the “closest” to the first line child.
Same thing for the second line except I want to find the closest term element, which in this case is “b”
How can I accomplish this reliably using LINQ?
If the
termelement always exactly precedes thelineelement, you can useSo