I'm new to programming but, I'm trying to load all entries of one single field in a XML file into a ListBox. This seems to properly load the XML file on executing the form but, I get an out of range exception with this code:
using System.Xml.Serialization;
using System.IO;
using System.Xml;
using System.Xml.Linq;
namespace TP1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
XmlDocument xmldocIntern = new XmlDocument();
xmldocIntern.Load(@"InternList.xml");
foreach (XmlNode node in xmldocIntern.DocumentElement)
{
string theTitle = node.Attributes[0].Value;
lstBxListIntern.Items.Add(theTitle);
}
}
This is a sample of my XML file:
<?xml version="1.0"?>
<ArrayOfInternship xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Internship>
<Title>Marketing</Title>
<Start>2019-03-08T00:00:00</Start>
<End>2019-04-12T00:00:00</End>
<Supervisor>John Smith</Supervisor>
<Comments>Web site makeover.</Comments>
</Internship>
</ArrayOfInternship>