Monday, February 27, 2012

Create Section With Complex Linq query


I'm trying to create a section with linq from xml file. my xml file build like this:




<root>
<Item>
<name>a</name>
<status>new</status>
</Item>
<Item>
<name>b</name>
<status>old</status>
</Item>

</root>



I want to create the section by the following way if the status tag = "new it will create an entry element and if its old it will create a stringelement



i thought of something like this




new section()
{
from x in myXdoc.Descendants("Item")
where x.element("Status").value == "new" || x.element("Status").value == "old"

??????

}

No comments:

Post a Comment