xml - C# : What should I use: Array or ArrayList or List of list? -


i'm learning c# , need advise.

i'm trying create users (active directory) xml file. users students , teachers. each user need name, surname, birthdate generate login, password.

  • a student can member of 1 groupe (his class).
  • a teacher can have 1 or more group (classes teaches).

all information need in xml.

in powershell, works :

  • students : tab[name,surname,birthdate,login,group] (and works in c#)
  • teachers : tab[name,surname,birthdate,login,tab[groups]]

how can in c# ? try array in 3d ugly , not performant hundreds of users ... there better way lists ? arraylist ?

sorry ma bad english ...

thanks (and pieces of code ^^) !

example of xml teachers :

<data> -<persons> --<person id="6022"> ---<name>doe</name> ---<surname>john</surname> ---<birhdate>1952-06-29</date_naissance> --</person> --... -</persons> -<classes> --<class code="3a"> ---<teachers> ----<teacher id="6022"> -----<subject>maths</subject> ----</teacher> ---</teachers> --</class> --<class code="5d"> ---<teachers> ----<teacher id="6022"> -----<subject>maths</subject> ----</teacher> ---</teachers> --</class> ... -</classes> </data> 

you might want take @ xdocument.

you can create 1 calling xdocument.parse("<mydoc></mydoc>")

example:

var xml = @"<data> <persons> <person id=""6022""> <name>doe</name> <surname>john</surname> <birhdate>19520629</birhdate> </person> </persons> <classes> <class code=""3a""> <teachers> <teacher id=""6022""> <subject>maths</subject> </teacher> </teachers> </class> <class code=""5d""> <teachers> <teacher id=""6022""> <subject>maths</subject> </teacher> </teachers> </class> </classes> </data>";  var doc = xdocument.parse(xml);  var peopleelements = doc     .elements("data")     .elements("persons")     .elements("person"); var q = person in peopleelements select new {     name = person.element("name").value,     birthdate = person.element("birhdate").value };  var peoplelist = q.tolist(); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -