title: Store multiple xml node into list and show in MVC view
body: <p>I will like to store multiple xml linq result into a list and show in mvc view but it stores null value when debugging. Anyway to store it in the List?
  Thanks!</p>
  
  <p>My Controller:</p>
  
  <pre><code>public ActionResult SURV_Answer_Result(int Survey_ID, string Language = "ENG")
  {
  List&lt;AnswerQuestionViewModel&gt; viewmodel = new List&lt;AnswerQuestionViewModel&gt;();
  
              var query = from r in db.SURV_Question_Ext_Model
                          join s in db.SURV_Question_Model
                          on r.Qext_Question_ID equals
                          s.Question_ID
                          select new { r, s };
  
              var viewModel = new AnswerQuestionViewModel();
              viewModel.Survey_ID = Survey_ID;
  
              List&lt;string&gt; AnsResult = new List&lt;string&gt;();
  
              foreach (var item in query.ToList())
              {
  
                  string str = item.s.Answer_Data;
                  XElement qconfig;
                  qconfig = XElement.Parse(str);
  
                  string value = item.s.Question_Type;
                  int i = 0;
  
                  switch (value)
                  {
  
                      case "Single_Line":
                          {
  
                                  XElement SingleLineAns =
                                  (from node in qconfig.Elements("Answer")
                                  select node).SingleOrDefault();
  
         Unable to store=====&gt;    viewModel.ResultAnswer = SingleLineAns.Value;       
                                  AnsResult.Add(viewModel.ResultAnswer[i]);
                                  i++;
  
                          }
                          break;
  
                      case "Multiple_Line":
                          {
                             // do nothing
                          }
                          break;
  
  
  
                  viewmodel.Add(new AnswerQuestionViewModel()
                  {              
                      ResultAnswer = viewModel.ResultAnswer        
                  });
              }
  
              return View(viewmodel);
          }
  }
  </code></pre>
  
  <p>My AnswerQuestionModel:</p>
  
  <pre><code>public string[] ResultAnswer { get; set; }
  </code></pre>
  
  <p>My View:</p>
  
  <pre><code>@model List&lt;SurveyTool.Models.AnswerQuestionViewModel&gt;
      @for(int i = 0; i &lt; Model.Count; i++)
      {
         @Html.DisplayFor(m =&gt; m[i].ResultAnswer[i])
      }
  </code></pre>
  
  <p>XML Answer Data Sample (will get 'ssd' after extract):</p>
  
  <pre><code>&lt;!--Question Configuration--&gt;&lt;AnswerData&gt;&lt;Answer&gt;ssd&lt;/Answer&gt;&lt;/AnswerData&gt;
  </code></pre>