Answer the question
In order to leave comments, you need to log in
xml. How to display elements in a particular node without their children?
Hello! I really ask for help. I rummaged through the entire Internet, I saw 1000 codes, but I did not find the one I needed. The question is:
There is an xml file structure:
<?xml version="1.0" encoding="UTF-8"?>
-<head>
-<Klassi>
<klass>Класс 1</klass>
<klass>Класс 2</klass>
<klass>Класс 3</klass>
<klass>Класс 4</klass>
<klass>Класс 5</klass>
-<klass>Класс 7<gruppa>А</gruppa><gruppa>Б</gruppa><gruppa>В</gruppa></klass></Klassi></head>
XmlDocument doc = new XmlDocument();
doc.Load("C:\\Gruppi.xml");
XmlNodeList nodeList = doc.SelectNodes("head/Klassi/klass");
listBox1.Items.Clear();
foreach (XmlNode node in nodeList)
{
listBox1.Items.Add(node.InnerText);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question