I am trying to generate an xml by serializing and facing some issues. Thereis a part of xml which is dynamic. the section "person" is dynamic i.e the sub sections
(name and age)under person can increase or decrease. I am able to serialie the class with static value( with single person name and age) but when getting multiple
values then I am not able to handle that.All the values are fetched from database and every name and age is store as a distinct row in database.So if I have 2 names and age then it will be stored
as 2 distinct rows in database. I tried to create a loop(on basis of number of rows) but not able understand how to incorporate the dynamic section to rest of xml part.
Can someone help on this?
create table persondetails(name varchar(20),age int)
insert into persondetails(name,age)
select 'Dann',21
union all
select 'Scott',23
union all
Select 'Allen',24
Desired output XML:
<details>
<description>Some description</description>
<hobby> Anything</hobby>
<person>
<name>Dann</name>
<age>21</age>
<name>Scott</name>
<age>23</name>
</person>
</details>