I’m working with XML that was designed by somebody who got paid by the level of nesting. The different xml files always looks something like this:
<Car> <Color> <Paint> <AnotherUselessTag> <SomeSemanticBs> <TheImportantData>
With LINQ its easy to get what I want: ( not exactly, but you get the point )
from x in car.Descendants('x') from y in x.Descendants('y') from z in y.Descendants('z') select z.WhatIWant();
I’m asking if there is a better way to do this? Some way of navigating the DOM with Linq?
If you are sure that all you want are
TheImporantDataelements from aCarelement and thatTheImportantDataisn’t used as a tag name else where then:-from x in car.Descendants(‘TheImportantData’) select x.WhatIWant();
Will do.