I have the following xml:
<?xml version="1.0" ?>
<course>
<globalProperties>
<externalMetadata>
<source>ADL</source>
<model>ADL SCORM 1.0</model>
</externalMetadata>
</globalProperties>
<block id="B1">
<identification>
<title>Yes/No Questions</title>
<description>This course has one lesson</description>
<labels>
<curricular>MODULE</curricular>
<developer>Me</developer>
</labels>
</identification>
<au id="A100001">
<externalMetadata>
<source>ADL</source>
<model>ADL SCORM 1.0</model>
</externalMetadata>
<identification>
<title>What is yes/no question</title>
<description>This slide describes the type of the question</description>
<labels>
<curricular>AU</curricular>
<developer>Me</developer>
</labels>
</identification>
<launch>
<location>slide1.htm</location>
</launch>
</au>
<au id="A100002">
<externalMetadata>
<source>ADL</source>
<model>ADL SCORM 1.0</model>
</externalMetadata>
<identification>
<title>Examples of yes/no questions</title>
<description>This slide provide examples</description>
<labels>
<curricular>AU</curricular>
<developer>Me</developer>
</labels>
</identification>
<launch>
<location>slide2.htm</location>
</launch>
</au>
<au id="A100003">
<externalMetadata>
<source>ADL</source>
<model>ADL SCORM 1.0</model>
</externalMetadata>
<identification>
<title>Test yourself</title>
<description>This slide checks what you have learned</description>
<labels>
<curricular>AU</curricular>
<developer>Me</developer>
</labels>
</identification>
<launch>
<location>slide3.htm</location>
</launch>
</au>
</block>
<block id="B2">
<identification>
<title>WH Questions</title>
<description>This course has one lesson</description>
<labels>
<curricular>MODULE</curricular>
<developer>Me</developer>
</labels>
</identification>
</block>
<block id="B3">
<identification>
<title>Other Question Types</title>
<description>This course has one lesson</description>
<labels>
<curricular>MODULE</curricular>
<developer>Me</developer>
</labels>
</identification>
</block>
</course>
I am trying to build a treeview that will hold the MODULEs and the AUs. When
I'm using the following code snippet:
foreach(XmlNode node in
doc.SelectNodes("//identification/labels[curricular='MODULE']/../title"))
{
t1 = new TreeNode(node.InnerText);
tree.Nodes.Add(t1);
foreach(XmlNode nod in
node.SelectNodes("//identification/labels[curricular='AU']/../title"))
{
t2 = new TreeNode(nod.InnerText);
t1.Nodes.Add(t2);
I'm getting the 3 AUs that are related to the first MODULE (titled "Yes/No
Questions") for all 3 modules. I want to get under each module only the AUs
that are under the same block - context. How should I implement that?
I was trying:
foreach(XmlNode node in
doc.SelectNodes("//block/identification/labels[curricular='MODULE']/../title"))
{
t1 = new TreeNode(node.InnerText);
tree.Nodes.Add(t1);
foreach(XmlNode nod in
node.SelectNodes("./au/identification/labels[curricular='AU']/../title"))
{
t2 = new TreeNode(nod.InnerText);
t1.Nodes.Add(t2);
but it didn't give me any au.
How can I do that?
Thanks