XML : insert and represent intra-document one to many relationship in xml

I have xml data as like following :

  <?xml version="1.0" encoding="UTF-8"?>  <classes>      <class room_id='1'>          <classArea></classArea>          <classFloor></classFloor>          <maxStudents></maxStudents>          <teachers>              <teacher_name></teacher_name>              <teacher_name></teacher_name>              <teacher_name></teacher_name>          </teachers>      </class>  </classes>    

in asp.net c# web app page I have created textboxes for room_id, classArea, classFloor, maxStudents to allow user to enter a new class, then I created XElement from it to represent xml data as following:

  XElement class = new XElement("class",                  new XAttribute("room_id", IdTb.Text),                  new XElement ("classArea"...                  ...                  ... maxStudents));    

adding text box for teacher_name force user to enter only one teacher per class.

my problem is how to allow user to enter multiple values for teacher_name element in teachers element at the same time? because we have multiple values for it, and I do not know how many teacher could be entered one...ten...or more. what should I use to solve this problem, and to build XElement "class" object with full structure at one shot like press save button? please lead me to solve it.

No comments:

Post a Comment