Wie finde ich einen bestimmten Knoten in meinem XML?
Ich muss den XML-Knoten "name" aus der folgenden XML-Datei lesen, weiß aber nicht, wie ich das machen soll.
Hier ist das XML:
<code><?xml version="1.0" standalone="yes" ?> <games> <game> <name>Google Pacman</name> <url>http:\\www.google.de</url> </game> </games> </code>
Code:
<code>using System.Xml; namespace SRCDSGUI { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { XmlDocument doc = new XmlDocument(); doc.Load(Application.StartupPath + @"\games.xml"); XmlElement root = doc.DocumentElement; XmlNodeList nodes = root.SelectNodes("//games"); foreach (XmlNode node in nodes) { listBox1.Items.Add(node["game"].InnerText); } } } } </code>