I'm trying to select elements based on the attributes of sub a element of that element.
Original Xml:
<Root>
<Element1 id="1">
<element2>XXXX</element2>
<element2>XXXX</element2>
<element2>XXXX</element2>
<Filter attr1="1" attr2="0" attr3="0" attr4="1" attr5="0"></Filter>
</Element1>
<Element1 id="2">
<element2>XXXX</element2>
<element2>XXXX</element2>
<element2>XXXX</element2>
<Filter attr1="1" attr2="0" attr3="0" attr4="1" attr5="0"></Filter>
</Element1>
<Element1 id="3">
<element2>XXXX</element2>
<element2>XXXX</element2>
<element2>XXXX</element2>
<Filter attr1="1" attr2="0" attr3="0" attr4="1" attr5="0"></Filter>
</Element1>
</Root>
This is what I've done so far:
Dim xmlElement = (From rec In RecipeXmlDocument.Descendants("RECEPT") _
Where (rec.Descendants("Filter").@poultry = Ing.Poultry.ToString() _
Or rec.Descendants("Filter").@attr1 = "1" _
Or rec.Descendants("Filter").@attr2 = "0" _
And (rec.Descendants("Filter").@attr3 = "1" _
Or rec.Descendants("Filter").@attr4 = "0" _
Or rec.Descendants("Filter").@attr5 = "1"
This throws the following error: "Exception of type 'System.Linq.SystemCore_EnumerableDebugViewEmptyException' was thrown."
What the code is trying to do is to select all the Element1s where the filter element of that element1 matches the where clause of the statement.
I'm fairly new to linq and i'm not exactly sure what I'm doing wrong.