let say i have xml with this format:
<TEST>
<DRINK>
<NAME>Ice tea</NAME>
<NAME>Milo</NAME>
<NAME>Coffee</NAME>
</DRINK>
<FOOD>
<NAME>Fried Rice</NAME>
<NAME>Hamburger</NAME>
<NAME>Fried Noodles</NAME>
</FOOD>
</TEST>
How to retrieve only food names and put in the asp.net webform textbox, this is my current code:
XmlDocument doc = new XmlDocument();
doc.Load(filepath);
root = doc.DocumentElement;
TextBox1.Text = root.GetElementsByTagName("NAME")[0].InnerText;
TextBox2.Text = root.GetElementsByTagName("NAME")[1].InnerText;
TextBox3.Text = root.GetElementsByTagName("NAME")[2].InnerText;
This code will instead retrieve drink names instead of food names. How to make it read NAME tags in FOOD tag?
CodePudding user response: