I'm just getting started using Linq to XML and I have a simple document with records like this:
<record date="6/27/2002" symbol="DG" price="15.00" />
I want a list of distinct symbols as strings, in order.
This gives me an unordered list of all attributes, but I'm stuck
var query =
from e in xml.Elements()
select e.Attribute("symbol");
How can this be modified to give me what I want?
How about:
var query = (from e in xml.Elements()
let symbol = (string)e.Attribute("symbol")
where symbol != null
orderby symbol
select symbol).Distinct();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With