How to display XML in a listbox and pass it to a textbox in C#?
<p>I'm struggling to make a basic C# app that gets a number of items from an XML file, shows the "title" node in a listbox, and, when a title is selected, displays the other nodes of the item in a textbox. The textbox is meant to allow the user to edit the XML content and save the changes. </p>

<p>My problem is quite basic I think: The listbox works fine, but the textbox isn't updated when a new title is selected in the listbox. I guess it shouldn't be too complicated, but to me it is - I'm really stuck here.</p>

<p>I'm aware that questions like this one pop up frequently, but most of them seem to me to be imprecise or overly complicated: I'm (obviously) new to C# and really like to keep code as simple and transparent as possible.</p>

<p>My XML sample:</p>

<pre><code>&lt;?xml version='1.0'?&gt;
  &lt;book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0"&gt;
    &lt;title&gt;The Autobiography of Benjamin Franklin&lt;/title&gt;
    &lt;author&gt;
      &lt;first-name&gt;Benjamin&lt;/first-name&gt;
      &lt;last-name&gt;Franklin&lt;/last-name&gt;
    &lt;/author&gt;
    &lt;price&gt;8.99&lt;/price&gt;
  &lt;/book&gt;
  &lt;book genre="novel" publicationdate="1967" ISBN="0-201-63361-2"&gt;
    &lt;title&gt;The Confidence Man&lt;/title&gt;
    &lt;author&gt;
      &lt;first-name&gt;Herman&lt;/first-name&gt;
      &lt;last-name&gt;Melville&lt;/last-name&gt;
    &lt;/author&gt;
    &lt;price&gt;11.99&lt;/price&gt;
  &lt;/book&gt;
  &lt;book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6"&gt;
    &lt;title&gt;The Gorgias&lt;/title&gt;
    &lt;author&gt;
      &lt;name&gt;Plato&lt;/name&gt;
    &lt;/author&gt;
    &lt;price&gt;9.99&lt;/price&gt;
  &lt;/book&gt;
&lt;/bookstore&gt;
</code></pre>

<p>The cs file</p>

<pre><code>private void btnLireXML_Click(object sender, EventArgs e)
{
    XmlDocument xDox = new XmlDocument();
    xDoc.Load(books.xml);

    XmlNodeList lst = xDoc.GetElementsByTagName("title");
    foreach (XmlNode n in lst)
    {
        listBox1.Items.Add(n.InnerText); 
    }   

}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    textBox1.Text = listBox1.SelectedItem.ToString();
}
</code></pre>

<p>Here, in the textbox part, I've tried almost everything...</p>

<p>The WFA file contains a button that loads the XML file, a listbox, and a textbox (perhaps it would be better to have a text box for each XML node)</p>