Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main
- {
- public List<B> BList{ get; set; }
- }
- public class B
- {
- public B()
- {
- ListA = new List<A>();
- }
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public string Email { get; set; }
- public List<A> ListA { get; set; }
- }
- public class A
- {
- public int Rating { get; set; }
- public int Weightage { get; set; }
- }
- Main main = new Main ();
- var xEle = new XElement("Root", from x in main.BList
- from te in x.A select new XElement("Child", new XElement("Weightage", te.Weightage), new XElement("FName", x.FirstName),new XElement("LName", x.Email) ));
- <Root>
- <Child>
- <Weightage>10</Weightage>
- <FName>ABC</FName>
- <LName>ABC@gmail.com</LName>
- </Child>
- <Child>
- <Weightage>20</Weightage>
- <FName>ABC</FName>
- <LName>ABC@gmail.com</LName>
- </Child>
- </Root>
- <Root>
- <Child>
- <Weightage>10</Weightage>
- <Weightage>20</Weightage>
- <FName>ABC</FName>
- <LName>ABC@gmail.com</LName>
- </Child>
- </Root>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement