mtcremin's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
New Members
Active Posts:
2 (0 per day)
Joined:
29-December 12
Profile Views:
1,210
Last Active:
User is offline Dec 30 2012 07:02 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   mtcremin has not set their status

Posts I've Made

  1. In Topic: LINQ to XML

    Posted 29 Dec 2012

    Thank you. That does the trick. I really appreciate your prompt reply.

    View PostCodingSup3rnatur@l-360, on 29 December 2012 - 12:19 PM, said:

    Hi,

    Thanks for the feedback. Do you mean a collection of all the people described by the XML file? If so, you can just use:

    var people = (from p in Xdocument.Load("People.xml").Descendants("Person")
                  select new Person { ID = int.Parse(p.Attribute("id").Value),
                                      Name = p.Element("Name").Value, 
                                      Age = int.Parse(p.Element("Age").Value), 
                                      Job = p.Element("Job").Value });
    
    


    Now you can iterate through people using a for-each loop to get every person in the xml file.

    EDIT: Xdocument in the above code should have an upper case D, but a forum bug keeps making it lower case.
  2. In Topic: LINQ to XML

    Posted 29 Dec 2012

    This was a very helpful article in understanding XML and LINQ. I am still struggling with it. In example where you read from the xml file for a person using a random number. This returns data to the Person object. Is there a way to return the collection of People? Then I could iterate through the collection of people?

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

mtcremin hasn't added any friends yet.

Comments

mtcremin has no profile comments yet. Why not say hello?