The tags 'school1', 'school2', 'grade1', 'grade2' are dynamically created. And number of
I want to read all
Since there are dynamic tags, I am able to read all
But I want to read them individually according to the grade.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kailash Polai195 reputationPosted Aug 17, 2017, 9:10 PM EDT
Midhun TpRank #388 · 6.5K reputationPosted Aug 17, 2017, 9:18 PM EDT
Parul Maheshwari11 reputationPosted Aug 22, 2017, 8:42 AM EDT
string studentAge = "";
List
List
List
List
foreach (XmlNode node in doc.SelectNodes("root/academic"))
{
for (int i = 0; i < node.ChildNodes.Count-1; i++ )
{
schoolName = node.ChildNodes[i].LocalName;
foreach (XmlNode node1 in doc.SelectNodes("root/academic/" + schoolName))
{
for(int j = 0; j < node1.ChildNodes.Count; j++)
{
gradeName = node1.ChildNodes[j].LocalName;
foreach(XmlNode node2 in doc.SelectNodes("root/academic/"+schoolName+"/"+gradeName))
{
foreach (XmlNode node3 in node2.ChildNodes)
{
if (node3.LocalName.Equals("student"))
{
studentName = node3.SelectSingleNode("name").InnerText;
studentAge = node3.SelectSingleNode("age").InnerText;
schoolList.Add(schoolName);
gradeList.Add(gradeName);
nameList.Add(studentName);
ageList.Add(studentAge);
}
}
} // grade foreach ends
} // grade for ends
} // school foreach ends
} // school for ends
}
Parul Maheshwari11 reputationPosted Aug 22, 2017, 8:43 AM EDT