I'm trying to select nodes using LINQ but I cannot understand why this simple query does not work.
My xml is like this:
<config>
<func_list current_app="GSCC" flag="0">
<func id="GSCC">
<BLOCKS>
<BLOCK id="1" type="ACTIONS">
<ITEMS>
<ITEM id="1" type="UINT32" size="1" value="1" />
<ITEM id="2" type="UINT32" size="1" value="5" />
<ITEM id="3" type="UINT32" size="1" value="0" />
</ITEMS>
</BLOCK>
</BLOCKS>
</func>
</func_list>
</config>
Now, I have an XElement (_funcNode) which points to 'func' node:
IEnumerable<XElement> xBlocks = from el in _funcNode.Descendants("BLOCK")
where el.Attribute("type").Value == "ACTIONS"
select el;
if (!xBlocks.Any()) return false;
Also the xBlocks.Any() throws an System.NullReferenceException exception. Any idea?
No comments:
Post a Comment