tags:

views:

46

answers:

1

I have some problems getting the data that i read from XML split into seperate columns. Any help this new C# coder would get would be appreciated.

XDocument xmlDoc = XDocument.Load("emails.xml");            

        var t = from c in xmlDoc.Descendants("dt")
                select (string)c.Element("name") + (string)c.Element("email");
        foreach (string item in t)
        {                   
               listView.Items.Add(item);
        } 
+1  A: 
XDocument xmlDoc = XDocument.Load("emails.xml");            

        var t = from c in xmlDoc.Descendants("dt")
                            select new
                            {
                                    Name = e.Element("name").Value,
                                    EMail = e.Element("email").Value,
                            };


        foreach (var item in t)
        {                   
               var lvi = listView.Items.Add(item.Name);
               lvi.SubItems.Add(item.EMail);
        } 
volody
My problem was that I wasnt sure how to split the parsed values into the seperate columns. Your code worked perfectly, thanks.
Zubirg