0

I'm trying to create a ticket system with XML in C#, but for some reason the values keep returning null. The Id Attribute is not null when getting it.

This is my loading method:

        XmlDocument doc = new XmlDocument();
        doc.Load("ticketdata.xml");



        foreach (XmlNode node in doc.DocumentElement) {
            int id = int.Parse(node.Attributes[0].Value);
            string user = node["user"].Value;
            string platform = node["platform"].Value;
            string ttext = node["ttext"].Value;

            tickets.Add(new Ticket(id, user, platform, ttext));

        }

This is my XML file:

XML File ( for some reason XML didn't work great in text)

I hope you guys could help me with this.

  • Follow the instructions. Debug your code, examine your variables and see why they would return null. Once you do this, if you haven't already found the issue, [edit] and update with what you did and what you found. Then, @ me in the comments here. –  Mar 17 '17 at 19:56
  • @Stannies: use InnerText instead of Value property. – Jiří Polášek Mar 17 '17 at 20:02
  • @JiříPolášek Thanks that worked! –  Mar 17 '17 at 20:22

0 Answers0