Hi,
I need to read XML file and put it in struct, then put the struct in list.
Please help. My code doesn't work.
My code:
using System;
using System.Xml;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace Zadatak11
{
class Program
{
public struct Restoran
{
public int id;
public string naziv;
public string opis;
public string adresa;
public string grad;
public int radno_vrijeme_od;
public int radno_vrijeme_do;
public Restoran(int i, string n, string o, string a, string g, int rvO, int rvD)
{
id = i;
naziv = n;
opis = o;
adresa = a;
grad = g;
radno_vrijeme_od = rvO;
radno_vrijeme_do = rvD;
}
}
static void Main(string[] args)
{
List<Restoran> restorani = new List<Restoran>();
string sXml = "";
StreamReader oSr = new StreamReader("J:\\Programiranje\\OsnoveProgramiranjaLV5\\Zadatak11\\Zadatak11\\restorani.xml");
using (oSr)
{
sXml = oSr.ReadToEnd();
}
XmlDocument oXml = new XmlDocument();
oXml.LoadXml(sXml);
XmlNodeList oNodes = oXml.SelectNodes("//data/restoran");
foreach (XmlNode oNode in oNodes)
{
}
}
}
}