title: How to read xml attributes into 2d list List<List<Double>>
body: <p>I am making an application which takes values from a textbox and saves them to a 2D list. I got it to save the list to an xml file, but I can't get it to add the attributes back to the list. The attribute exists. I used a messagebox popup to see if its retrieving the attribute correctly and it is. But for some reason it's not adding it to the list. In fact it's not even loading the other information to the listview.</p>
  
  <pre><code>    public void Load(RadListView listView, List&lt;List&lt;double&gt;&gt; list)
      {
          XDocument doc = XDocument.Load(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RentData.xml"));
          foreach (var dm in doc.Descendants("Month"))
          {
              ListViewDataItem item = new ListViewDataItem();
              foreach (XElement x in dm.Descendants())
              {
  
                  List&lt;double&gt; sublist = new List&lt;double&gt;();
                  sublist.Capacity = 6;
                  if (x.Name == "Mike")
                  {
                      sublist.Insert(0, Convert.ToDouble(x.Attribute("Rent").Value));
                      sublist.Insert(2, Convert.ToDouble(x.Attribute("Internet").Value));
                      sublist.Insert(4, Convert.ToDouble(x.Attribute("Electricty").Value));
                      sublist.Insert(6, Convert.ToDouble(x.Attribute("Water").Value));
                  }
                  else if (x.Name == "Patti")
                  {
                      sublist.Insert(1, Convert.ToDouble(x.Attribute("Rent").Value));
                      sublist.Insert(3, Convert.ToDouble(x.Attribute("Internet").Value));
                      sublist.Insert(5, Convert.ToDouble(x.Attribute("Electricty").Value));
                      sublist.Insert(7, Convert.ToDouble(x.Attribute("Water").Value));
                  }
                  else
                  {
                       item.SubItems.Add(x.Value); 
                  }
                  list.add(sublist);
              }
  
  
              item.TextAlignment = ContentAlignment.MiddleCenter;
              listView.Items.Add(item);
          }
      }
  </code></pre>
  
  <p>EDIT: Xml files </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!--Rent Calculator Save Data--&gt;
  &lt;Rent&gt;
    &lt;Month&gt;
      &lt;Date&gt;01/15/2015&lt;/Date&gt;
      &lt;Rent&gt;$100.00&lt;/Rent&gt;
      &lt;Internet&gt;$110.00&lt;/Internet&gt;
      &lt;Water&gt;$120.00&lt;/Water&gt;
      &lt;Electricity&gt;$130.00&lt;/Electricity&gt;
      &lt;totalExepense&gt;$460.00&lt;/totalExepense&gt;
      &lt;Payments&gt;
        &lt;Patti Water="60" Electricity="65" Internet="55" Rent="50" /&gt;
        &lt;Mike Water="60" Electricity="65" Internet="55" Rent="50" /&gt;
      &lt;/Payments&gt;
    &lt;/Month&gt;
  &lt;/Rent&gt;
  </code></pre>
  
  <p>AND the code used to write to xml:</p>
  
  <pre><code>public void Write(RadListView listView, List&lt;List&lt;double&gt;&gt; list)
      {
          XmlWriterSettings settings = new XmlWriterSettings() { Indent = true };
          XmlWriter writer = XmlWriter.Create(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RentData.xml"), settings);
          writer.WriteStartDocument();
          writer.WriteComment("Rent Calculator Save Data");            
          writer.WriteStartElement("Rent");
          for (int a = 0; a &lt; listView.Items.Count; a++ )
          {
              foreach (ListViewDataItem i in listView.Items)
              {
                  writer.WriteStartElement("Month");
                  writer.WriteElementString("Date", i[0].ToString());
                  writer.WriteElementString("Rent", i[1].ToString());
                  writer.WriteElementString("Internet", i[2].ToString());
                  writer.WriteElementString("Water", i[3].ToString());
                  writer.WriteElementString("Electricity", i[4].ToString());
                  writer.WriteElementString("totalExepense", i[5].ToString());
                  writer.WriteStartElement("Payments");
                  writer.WriteStartElement("Patti");
                  writer.WriteAttributeString("Water", list[a][6].ToString());
                  writer.WriteAttributeString("Electricity", list[a][4].ToString());
                  writer.WriteAttributeString("Internet", list[a][2].ToString());
                  writer.WriteAttributeString("Rent", list[a][0].ToString());
                  writer.WriteEndElement();
                  writer.WriteStartElement("Mike");
                  writer.WriteAttributeString("Water", list[a][7].ToString());
                  writer.WriteAttributeString("Electricity", list[a][5].ToString());
                  writer.WriteAttributeString("Internet", list[a][3].ToString());
                  writer.WriteAttributeString("Rent", list[a][1].ToString());
                  writer.WriteEndElement();
                  writer.WriteEndElement();
                  writer.WriteEndElement();
              }
          }
          writer.WriteEndDocument();
          writer.Flush();
          writer.Close();
      }
  </code></pre>