Question:You are implementing an ASP.NET web application.The application defines the following classes. public class Person { public String Name{get; set;} publicIList<Address> Addresses{get;set;} } public class Address { public String AddressType{get; set;} public string AddressValue{get;set;} } The applicaction must generate XML from personList, wich is a collection of Person instances.The following XML is an example of the schema than the generated XML must use. <Persons> <Person Name="John Doe"> <Address Email="John.Doe@contoso.com"/> <Address AlternativeEmail="John.Doe@contoso.com"/> <Address MSNInstanceMessenger="John.Doe@contoso.com"/> </Person> ..... </Persons> You need to generate the XML. Wich code segment should you use? 

A var XML= new XElement("Persons", from person in personList Select (new XElement("Persons", newXElement("Name", person.Name), from addr in person.Addresses select new XElement("Address", newXElement(addr.AddressType, addr.AddressValue))))); 

B var XML= new XAttribute("Persons", from person in personList Select (new XElement("Persons", newXAttribute("Name", person.Name), from addr in person.Addresses select new XAttribute("Address", newXAttribute(addr.AddressType, addr.AddressValue))))); 

C var XML= new XElement("Persons", from person in personList Select (new XElement("Persons", newXAttribute("Name", person.Name))) 

D var XML= new XElement("Persons", from person in personList Select (new XElement("Person", newXAttribute("Name", person.Name), from addr in person.Addresses select new XElement("Address", newXAttribute(addr.AddressType, addr.AddressValue))))); 

+ Answer
+ Report
Total Preview: 1051

Copyright © 2024. Powered by Intellect Software Ltd