TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Denis Majfez
NA
5
524
XML file to struct
Dec 1 2019 10:54 AM
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)
{
}
}
}
}
Reply
Answers (
2
)
Desired Output of a separator
How to add Multiple models in collection ?