Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6944183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:15:11+00:00 2026-05-27T13:15:11+00:00

I am a university student taking a HCI design course, and using C# and

  • 0

I am a university student taking a HCI design course, and using C# and WPF for the first time. I have read a little about xml, and it seems like a good way to get input for use in my program. I have an XML file i made that contains a list of houses and there peramaters, like so:

<house>
    <Price>400000</price>
    <neighborhood>BrentWood</neighborhood>
    <description>This is a so and so house, located...</description>
</house>
<house>
    <Price>300000</price>
    <neighborhood>BrentWood</neighborhood>
    <description>This is a so and so house, located...</description>
</house>

And i have a house class like so:

public class house{
    public house(int price, string neighborhood, string description){
        this.price = price;
        this.neighborhood = neighborhood;
        this.description = description;
    }
    public int price;
    public string neighborhood;
    public string description;
}

I have read a little about xml, but i cant seems to find a tutorial to make a function that takes the xml file as input, and returns a List of newly created house objects. Can anyone show me how this is done? Or maybe suggest a better way of defining the house objects in a file, and loading them as house objects?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:15:12+00:00Added an answer on May 27, 2026 at 1:15 pm

    This should get you started using LINQ to XML:

    XDocument housesXml = XDocument.Load("houses.xml");
    
    List<House> houses =
        housesXml.Root.Elements("house")
        .Select(h => new House(
            int.Parse(h.Element("price").Value),
            (string) h.Element("neighborhood"),
            (string) h.Element("description")
        ))
        .ToList();
    

    (Also, wrap your <house> elements in an outer <houses></houses> root tag, and take care to match case, <Price></price> should be <price></price>)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First a little background: - I'm a first time poster, a student in university
I have three tables STUDENT, DEPARTMENT and COURSE in a University database... STUDENT has
I'm a undergrad Student at a German University. I have a team Programming Course
I have two Entities University courses Course students i want to access all the
I am a university student. I have been working a lot with Android lately
For my university assignment I have to design some basic managment system for sicknesses
I am a university student and need to submit a coursework using iSQL* Plus
I'm a computer science college student. Yesterday, I have a class about Binary Search
I'm an undergraduate university student who also writes iPhone applications. Next year I'm expected
I am a university student and trying to write a program to solve 1-D

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.