Problem : I have data I've saved into an XML file, but when I re-open the application, the data in the XML file should be populating my listbox but nothing shows up. I've been at this for 2 hours and cannot find the problem.
My code to load xml file :
public void Load()
{
XDocument myDoc = XDocument.Load(".../.../parking.xml");
var ticks = from xElem in myDoc.Descendants("Ticket")
select new Ticket
{
TimeIn = Convert.ToDateTime(xElem.Element("TimeIn").Value),
TicketNum = Convert.ToInt32(xElem.Element("TicketNumber").Value),
};
this.Clear();
AddRange(ticks);
}
And my code to try to populate the listbox :
{
newList = new TickList();
newList.Load();
foreach (var nTick in newList)
{
spotList.Items.Add(nTick.ToString());
}
}
EDIT : http://pastebin.com/YwPj0Nxc
Couldn't find a good way to format that on this site, but that's the XML file.
Smurf Edit: Adding pastebin XML
<?xml version="1.0" encoding="utf-8"?>
<Tickets>
<Ticket>
<TicketNum>1</TicketNum>
<TimeIn>2012-10-11T17:49:49.896445-05:00</TimeIn>
</Ticket>
<Ticket>
<TicketNum>2</TicketNum>
<TimeIn>2012-10-11T17:49:50.2714664-05:00</TimeIn>
</Ticket>
<Ticket>
<TicketNum>3</TicketNum>
<TimeIn>2012-10-11T17:49:50.4304755-05:00</TimeIn>
</Ticket>
<Ticket>
<TicketNum>4</TicketNum>
<TimeIn>2012-10-11T17:49:50.5944849-05:00</TimeIn>
</Ticket>
</Tickets>