I am working on asp.net mvc 4 web api. I have a class like,
public class Quiz
{
public int QuizId{get; set;}
public string title{get; set;}
...
...
}
and now i am trying to retrieve list of quizs so i wrote like,
public List<Quiz> GetQuizs()
{
return repository.ListQuizs();
}
i need xml response so i have made configuration in webapi.config file like,
config.Formatters.XmlFormatter.UseXmlSerializer = true;
and i got a response like,
<ArrayOfQuiz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Quiz>
<QuizId>4</QuizId>
<title>Master Minds</title>
</Quiz>
<Quiz>
<QuizId>5</QuizId>
<title>Master Minds</title>
</Quiz>
</ArrayOfQuiz>
but i want the response like
<Quizs>
<Quiz>
<QuizId>4</QuizId>
<title>Master Minds</title>
</Quiz>
<Quiz>
<QuizId>5</QuizId>
<title>Master Minds</title>
</Quiz>
</Quiz>
i have tried like,
public class quizs:List<Quiz>{}
public class Quiz
{
//properties here
}
but i am unable to load list of quizs into quizs class. please guide me.