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 86699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:17:13+00:00 2026-05-10T22:17:13+00:00

I have a XML File like that <?xml version=1.0 encoding=utf-8 ?> <Configurations> <EmailConfiguration> <userName>xxxx</userName>

  • 0

I have a XML File like that

<?xml version='1.0' encoding='utf-8' ?>      <Configurations>              <EmailConfiguration>                 <userName>xxxx</userName>                 <password>xxx</password>                 <displayName>xxxxx</displayName>                 <hostAddress>xxxx</hostAddress>                 <sslEnable>xxx</sslEnable>                 <port>xxx</port>             </EmailConfiguration>              <LogConfiguration>                 <logEnable>true</logEnable>                 <generalEnable>true</generalEnable>                 <warningEnable>true</warningEnable>                 <errorEnable>true</errorEnable>             </LogConfiguration>          </Configurations> 

and I am using it as config file for my code and I want to retrieve their values (innerText) like that

bool logEnable = value comes from XML (logEnable) bool warningEnable = value comes from XML (warningEnable) bool errorEnable = value comes from XML (errorEnable) bool generalEnable = value comes from XML (generalEnable) 

So how can I read their values to assign them to the boolean variables and if I wanted to change one of their values with false, How would I be able to do that ?

Thanks…

Regards…

P.s : If you wrote more explanatory codes, It would be so much appreciated.

Thanks again…

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T22:17:14+00:00Added an answer on May 10, 2026 at 10:17 pm
    public class Options {     public string UserName { get; set; }     public string Password { get; set; }     public string DisplayName { get; set; }     public string HostAddress { get; set; }     public bool SSL { get; set; }     public string Port { get; set; }      public bool LogEnable { get; set; }     public bool GeneralEnable { get; set; }     public bool WarningEnable { get; set; }     public bool ErrorEnable { get; set; }      public static Options Load(string path)     {         Options options = new Options();         XmlDocument xml = new XmlDocument();         xml.Load(path);          XmlNodeReader input = new XmlNodeReader(xml);          while (input.Read())         {             var elementname = input.Name.ToLower();              switch (elementname)             {                 case 'username':                     options.UserName = input.Value;                     break;                 // all other cases                 case 'logenable':                     options.LogEnable = Boolean.Parse(input.Value);                     break;                 // continue with other cases             }         }     }      public static void Save(Options options, string path)     {         XmlTextWriter writer = new XmlTextWriter(path);          xmlWriter.WriteStartDocument(true);         xmlWriter.WriteStartElement('configuration');         xmlWriter.WriteStartElement('emailConfiguration');          xmlWriter.WriteStartElement('userName');         xmlWriter.WriteString(options.UserName);         xmlWriter.WriteEndElemement();          // continue for all elements          xmlWriter.WriteEndElement();         xmlWriter.WriteStartElement('logConfiguration');          xmlWriter.WriteStartElement('logEnable');         xmlWriter.WriteString(options.LogEnable.ToString());         xmlWriter.WriteEndElemement();          // continue for all elements          xmlWriter.WriteEndElement();         xmlWriter.WriteEndElement();          xmlWriter.Close();     } } 

    I left some work for you to complete 😉 Also, I didn’t write this is Visual Studio, and I didn’t compile it before hand. This code is provided as is with no guarantee or warranty. 😉

    This is basic XML Read/Write process in .NET, though there are many options. You could use XPath queries, or if you are using .NET 3.5 you could use Linq to Sql which will give you street cred with the cool kids. But the above sample should get you up and running quickly, just promise you’ll go do some research on these other things too, you’ll be all the better for it.

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

Sidebar

Related Questions

I would like to have an xml config file as follows: <?xml version=1.0 encoding=utf-8
i have a config file like this: ?xml version=1.0 encoding=utf-8 ? configuration appSettings add
is it possible to have app.config file like this : <?xml version=1.0 encoding=utf-8 ?>
The top of my web.xml file looks like this: <?xml version=1.0 encoding=UTF-8?> <web-app xmlns=http://java.sun.com/xml/ns/j2ee
I have an XML file that starts like this: <Elements name=Entities xmlns=XS-GenerationToolElements> I'll have
I have an xml file like this: <root> <item> <name>one</name> <status>good</status> </item> <item> <name>two</name>
I have an XML file, which I open in F# like this: let Bookmarks(xmlFile:string)
I have an XML configuration file with a collection of strings like so: <SomeSetting>value</SomeSetting>
I have an xml file providing data for a datagrid in Flex 2 that
I am using struts2, for that my struts.xml file contains code like : <?xml

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.