tags:

views:

43

answers:

1

I have the following tags

<NodeA desc="Household">
    <NodeA desc="Cheap"> 
       <NodeA desc="Cheap Item 1" category="Cooking" />   
       <NodeA desc="Cheap Item 2" category="Gardening" />
    </NodeA>
 </NodeA>
 <NodeA> ...and so on

With the help of a helpful guy here, I got to retrieve list of category using this:

.Where(attr => attr.Name == "category")
.Select(attr => attr.Value);

Now i want to retrieve both 'desc' and 'category'. How can I do this?

+2  A: 

Something like this.... (untested)

from c in context
where c.Attribute("category") == "category name"
select new
{
  Description = c.Attribute("desc"),
  Category =  c.Attribute("category")
}

Completely untested, but something along those lines should work.

Ian P
how do I do this using Lamda exp?
Not sure.. You could try: (from c in context select new { Description = c.Attribute("desc"), Category = c.Attribute("category") }).Where(c => c.Category == "category");But that's probably not what you want.
Ian P