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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:07:16+00:00 2026-06-11T02:07:16+00:00

As part of my installation process, I update some values in my app.config files,

  • 0

As part of my installation process, I update some values in my app.config files,
The file is built and indented in a way that helps the user read the values.
It’s built in sections, each section is an XElement and each value is an XAttribute.

This is a sample for the sections:

<DataAccessSection
  DataMappingFile = "Data\Mapping.xml"
  SchemaKeyWord = "[generated]"
/>
<ServiceManagementSection
  ServerName = "dummy"
  ServerIP = "1.0.0.0"
  Port = "1"
/>

I edit the file using an XDocument, accessing the XElement of the section and changing the XAttribute’s value, and then saving the changes using xDocument.Save(fullpath);

After the file is saved, the structure of the config file is this:

<DataAccessSection DataMappingFile="Data\Mapping.xml" SchemaKeyWord="[generated]" />
<ServiceManagementSection ServerName="dummy" ServerIP="1.0.0.0" Port="1" />

This structure is not so clear to the users, how do I keep the file in the initial structure and change only the values and not the indentation?

I could open and edit it as a simple text file, but it seems silly to access it like a text file when I have the power of a structured XML file.

EDIT:
Thanks for your answers.

I tried the solutions in the answers, but it keeps removing my white spaces and the indentation.
I also tried to load using:

XDocument.Load(fullPath, LoadOptions.PreserveWhiteSpaces);

But it doesn’t fix my problem.
The only thing that keeps all the whitespaces is loading it as a text file, and editing using String manipulation, but I don’t want to to that.

Does anyone has a different approach that will fix this problem?

Maybe using a different package for XML editing?

  • 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-06-11T02:07:18+00:00Added an answer on June 11, 2026 at 2:07 am

    Use LoadOptions.PreserveWhitespace when you calling to xDocument.Load and SaveOptions.DisableFormatting when you Saving

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

Sidebar

Related Questions

As part of the installation process I would like to copy a config file
I have an application that changes some registry values during installation. I am changing
I have this installation file setup.exe that was created with installShield wizard. as part
Part of my app caches web pages for offline viewing. To do that, I
Part of an app I am working on includes a log file viewer, with
As part of a testing process I finished the installation in "System Copy" mode
In my site there have an installation part.In that the database is imported(the datbase
I have an MSI installer that was built from a VS2010 setup project. Part
I created an installer that run vcredist_x86.exe (version 9.0.x.x) as part of the installation.
I'm getting this error on the make install part of the installation process. ld:

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.