I am developing asp.net mobile application. I am using XML as a database. I am using the following query for required output. In the XML file I have the collection of MIMIC nodes & inside MIMICS node I have collection of SECTION nodes. One or more more SECTION node contains one or more SECTION nodes ( nested SECTION node) In the SECTION node I have DATAITEM as follows
<MIMIC ID="3" NAME="Network Status">
<SECTIONS>
<SECTION ID="1" NAME="SDA Server 1" HAS-SUBSECTIONS="TRUE">
<DATAITEM NAME="ABC">XYZ</DATAITEM>
<SECTION ID="2" NAME="Top Side">
<DATAITEMS>
<DATAITEM>Not Available</DATAITEM>
</DATAITEMS>
</SECTION>
<SECTION ID="3" NAME="Subsea" HAS-SUBSECTIONS="TRUE">
<SECTION ID="4" NAME="SDA">
<DATAITEMS>
<DATAITEM NAME="SEMA">
<ATTRIBUTE NAME="TYPE" VALUE="?" APPEND-TAG-NAME-BY ="?"/>
<ATTRIBUTE NAME="TagName" VALUE="?"/>
<ATTRIBUTE NAME="OPCTagName" VALUE="?"/>
</DATAITEM>
<DATAITEM NAME="SEMB">
<ATTRIBUTE NAME="TYPE" VALUE="?" APPEND-TAG-NAME-BY ="?"/>
<ATTRIBUTE NAME="TagName" VALUE="?"/>
<ATTRIBUTE NAME="OPCTagName" VALUE="?"/>
</DATAITEM>
</DATAITEMS>
</SECTION>
<SECTION ID="5" NAME="Manifolds" HAS-SUBSECTIONS="TRUE">
For the above XML file I am using following XML query
string MIMIC_ID = "3";
string SECTION_ID = "1";
var QueryResultSet = from Mimic in FieldRoot.Element("USER-INTERFACE-DEFINITION").Element("MIMICS").Descendants("MIMIC")
.Where(e => e.Attribute("ID").Value == MIMIC_ID)
from DataItem in Mimic.Descendants("SECTION")
.Where(e => e.Attribute("ID").Value == SECTION_ID)
.Descendants("DATAITEM")
select DataItem;
In the above XML query I want to access the DATAITEM node only for the SECTION node whose ID=1. But I am getting all the DATAITEM node whose SECTION ID is 2,3,4,5. I think it is because I am using the Mimic.Descendants("SECTION"). Is there any other method which can replace the Mimic.Descendants("SECTION") method so that I can access the DATAITEM node only for SECTION node whose ID=1 ? Can you provide me the code or any link through which I can resolve the above issue