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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:43:06+00:00 2026-06-10T04:43:06+00:00

I’m trying to code a function that validates an XML settings file, so if

  • 0

I’m trying to code a function that validates an XML settings file, so if a node does not exist on the file, it should create it.

I have this function

private void addMissingSettings() {
    XmlDocument xmldocSettings = new XmlDocument();
    xmldocSettings.Load("settings.xml");

    XmlNode xmlMainNode = xmldocSettings.SelectSingleNode("settings");

    XmlNode xmlChildNode = xmldocSettings.CreateElement("ExampleNode");
    xmlChildNode.InnerText = "Hello World!";

    //add to parent node
    xmlMainNode.AppendChild(xmlChildNode);
    xmldocSettings.Save("settings.xml");
}

But on my XML file, if I have

<rPortSuffix desc="Read Suffix">&#13;&#10;</rPortSuffix>
<wPortSuffix desc="Write Suffix">&#03;</wPortSuffix>

When the I save the document, it saves those lines as

<rPortSuffix desc="Read Suffix">
</rPortSuffix>
<wPortSuffix desc="Sufijo en puerto de escritura">&#x3;</wPortSuffix>
<ExampleNode>Hello World!</ExampleNode>

Is there a way to prevent this behaviour? Like setting a working charset or something like that?

  • 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-10T04:43:07+00:00Added an answer on June 10, 2026 at 4:43 am

    The two files are equivalent, and should be treated as being equivalent by all XML parsers, I believe.

    Additionally, Unicode character U+0003 isn’t a valid XML character, so you’ve fundamentally got other problems if you’re trying to represent it in your file. Even though that particular .NET XML parser doesn’t seem to object, other parsers may well do so.

    If you need to represent absolutely arbitrary characters in your XML, I suggest you do so in some other form – e.g.

    <rPortSuffix desc="Read Suffix">\u000c\u000a</rPortSuffix>
    <wPortSuffix desc="Write Suffix">\u0003</wPortSuffix>
    

    Obviously you’ll then need to parse that text appropriately, but at least the XML parser won’t get in the way, and you’ll be able to represent any UTF-16 code unit.

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

Sidebar

Related Questions

I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
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 am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/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.