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

  • SEARCH
  • Home
  • 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 3443220
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:45:52+00:00 2026-05-18T08:45:52+00:00

I’m trying to decide on the best way to load in some configuration settings.

  • 0

I’m trying to decide on the best way to load in some configuration settings. Basically, I have an application that several people will log into, and once they’ve logged in, I want to load all of their settings (for example: colors, font sizes, personal records, etc.)

I was thinking of using an XML file to do this because I thought it would be fairly easy to parse in .NET, but it seems to be more difficult that I anticipated.

<ProgramSettings>   
  <database file="C:\database.mdb" />    
</ProgramSettings>

<UserSettings>
  <user key="user1">
    <layout color="red" fontsize="5" />
    <data file="C:\test1.txt" />
  </user>

  <user key="user2">
    <layout color="blue" fontsize="2" />
    <data file="C:\test2.txt" />
  </user>

</UserSettings>

Note: For some reason some of the code is not appearing, but basically there are major sections labeled “ProgramSettings” and “UserSettings.”
Edit: Thanks whoever fixed that for me.

Anyway, what I would like to do is get the “user key” which will be the user’s login name or something. Then, it would be nice to be able to do something like this:

String userLogin = "user1";

// returns red
String color = myXMLFile["UserSettings"][userLogin]["layout"]["color"];         

// returns 5
String fontSize = myXMLFile["UserSettings"][userLogin]["layout"]["fontsize"];   

Is anything like this possible? All the research I’ve done seems to indicate that you need to loop through each value. I’d like to load the whole file, and access any element directly.

It would also be cool if you could edit the values like:

myXMLFile["UserSettings"][userLogin]["layout"]["fontsize"] = "green";
  • 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-18T08:45:53+00:00Added an answer on May 18, 2026 at 8:45 am

    I think a fairly comfortable way of dealing with XML files in C# is using Linq to XML.

    using (FileStream lStream = new FileStream("ConfigurationSettings.xml", FileMode.Open, FileAccess.Read))
    {
         XElement lRoot = XElement.Load(lReader)
         string userLogin = "user1";
         XElement user = lRoot.Element("UserSettings").Elements("user").Where(x => x.Attribute("Key").Value == userLogin).FirstOrDefault();
          if (user != null)
          {
              // returns red
              string color = user.Element("layout").Attribute("color").Value;
    
              // returns 5
              string fontSize = user.Element("layout").Attribute("fontsize").Value;
          }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.