Note that there are some explanatory texts on larger screens.

plurals
  1. POError in selecting part of the xml document using linq
    primarykey
    data
    text
    <p>Hi this is my xml file. I want to select the level4 module's modulecode, moduletiltle and credits, but when i used Descendants node it will showed me all descendant nodes for all levels. but i want the linq query for selection only level4 module information</p> <pre><code>&lt;myCourse&gt; &lt;courseName&gt;BEng Mobile and Web Computing&lt;/courseName&gt; &lt;courseStructure&gt; &lt;level4&gt; &lt;module&gt; &lt;moduleCode&gt;ECSC401&lt;/moduleCode&gt; &lt;moduleTitle&gt;Programming Methodology&lt;/moduleTitle&gt; &lt;credits&gt;15&lt;/credits&gt; &lt;semester&gt;1&lt;/semester&gt; &lt;/module&gt; &lt;module&gt; &lt;moduleCode&gt;ECSC404&lt;/moduleCode&gt; &lt;moduleTitle&gt;Computer Systems Fundamentals&lt;/moduleTitle&gt; &lt;credits&gt;15&lt;/credits&gt; &lt;semester&gt;1&lt;/semester&gt; &lt;/module&gt; &lt;/level4&gt; &lt;level5&gt; &lt;module&gt; &lt;moduleCode&gt;ECSE501&lt;/moduleCode&gt; &lt;moduleTitle&gt;Object Oriented Development&lt;/moduleTitle&gt; &lt;credits&gt;30&lt;/credits&gt; &lt;semester&gt;0&lt;/semester&gt; &lt;/module&gt; &lt;module&gt; &lt;moduleCode&gt;ECWM506&lt;/moduleCode&gt; &lt;moduleTitle&gt;Mobile Computing Principles&lt;/moduleTitle&gt; &lt;credits&gt;15&lt;/credits&gt; &lt;semester&gt;1&lt;/semester&gt; &lt;/module&gt; &lt;/level5&gt; &lt;/courseStructure&gt; &lt;/myCourse&gt; </code></pre> <p>My code to select level4 descendants:</p> <pre><code>var query = from r in xmlDoc.Element("level4").Descendants("module") select new { moduleCode=r.Element("moduleCode").Value, moduleTitle = r.Element("moduleTitle").Value, credits = r.Element("credits").Value }; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload