Results 1 to 5 of 5

Thread: Retrieving a list from a XML to LINQ query

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    Question Retrieving a list from a XML to LINQ query

    vb.net Code:
    1. public class FeedDefinition
    2.     {
    3.         public string Name { get; set; }
    4.         public string Url { get; set; }
    5.     }
    6.  
    7.         public List<FeedDefinition> LoadFeeds(string path)
    8.         {
    9.             XDocument feedXML = XDocument.Load(path);
    10.  
    11.             var feeds = from feed in feedXML.Descendants("Feed")
    12.                         select new FeedDefinition
    13.                         {
    14.                             Name = feed.Element("Name").Value,
    15.                             Url = feed.Element("Url").Value
    16.                         };
    17.  
    18.             return feeds.ToList();
    19.         }

    This code returns a list with each element queried from the feed, how does it "work"? In other words, first the names and then the Urls? How?

    Thanks in advance.

    I've attached a picture of the xml file model.

    It was obtained from here.
    Attached Images Attached Images  
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width