c# - Serialize Dotnet Collection without Root Element? -
consider following serialized xml:
<course> <title>engineering</title> <student> <name>john doe</name> </student> <student> <name>jane doe</name> </student> ... </course>
unfortunately not in position modify schema. (ideally should have wrapped student
class students
root element!)
how define entity classes serialization work properly?
i tried following code, generates xml students
wrapper element.
public class course { public string title { get; set; } public list<student> students { get; set; } } public class student { public string name { get; set; } }
add xmlelement
attribute students
list, this:
public class course { public string title { get; set; } [xmlelement("student")] public list<student> students { get; set; } }
Comments
Post a Comment