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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:22:35+00:00 2026-05-10T18:22:35+00:00

I’ve got to get a quick and dirty configuration editor up and running. The

  • 0

I’ve got to get a quick and dirty configuration editor up and running. The flow goes something like this:

configuration (POCOs on server) are serialized to XML.
The XML is well formed at this point. The configuration is sent to the web server in XElements.
On the web server, the XML (Yes, ALL OF IT) is dumped into a textarea for editing.
The user edits the XML directly in the webpage and clicks Submit.
In the response, I retrieve the altered text of the XML configuration. At this point, ALL escapes have been reverted by the process of displaying them in a webpage.
I attempt to load the string into an XML object (XmlElement, XElement, whatever). KABOOM.

The problem is that serialization escapes attribute strings, but this is lost in translation along the way.

For example, let’s say I have an object that has a regex. Here’s the configuration as it comes to the web server:

<Configuration>   <Validator Expression='[^&lt;]' /> </Configuration> 

So, I put this into a textarea, where it looks like this to the user:

<Configuration>   <Validator Expression='[^<]' /> </Configuration> 

So the user makes a slight modification and submits the changes back. On the web server, the response string looks like:

<Configuration>   <Validator Expression='[^<]' />   <Validator Expression='[^&]' /> </Configuration> 

So, the user added another validator thingie, and now BOTH have attributes with illegal characters. If I try to load this into any XML object, it throws an exception because < and & are not valid within a text string. I CANNOT CANNOT CANNOT CANNOT use any kind of encoding function, as it encodes the entire bloody thing:

var result = Server.HttpEncode(editedConfig);

results in

&lt;Configuration&gt;   &lt;Validator Expression='[^&lt;]' /&gt;   &lt;Validator Expression='[^&amp;]' /&gt; &lt;/Configuration&gt; 

This is NOT valid XML. If I try to load this into an XML element of any kind I will be hit by a falling anvil. I don’t like falling anvils.

SO, the question remains… Is the ONLY way I can get this string XML ready for parsing into an XML object is by using regex replaces? Is there any way to ‘turn off constraints’ when I load? How do you get around this???


One last response and then wiki-izing this, as I don’t think there is a valid answer.

The XML I place in the textarea IS valid, escaped XML. The process of 1) putting it in the text area 2) sending it to the client 3) displaying it to the client 4) submitting the form it’s in 5) sending it back to the server and 6) retrieving the value from the form REMOVES ANY AND ALL ESCAPES.

Let me say this again: I’M not un-escaping ANYTHING. Just displaying it in the browser does this!

Things to mull over: Is there a way to prevent this un-escaping from happening in the first place? Is there a way to take almost-valid XML and ‘clean’ it in a safe manner?


This question now has a bounty on it. To collect the bounty, you demonstrate how to edit VALID XML in a browser window WITHOUT a 3rd party/open source tool that doesn’t require me to use regex to escape attribute values manually, that doesn’t require users to escape their attributes, and that doesn’t fail when roundtripping (&amp;amp;amp;amp;etc;)

  • 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. 2026-05-10T18:22:35+00:00Added an answer on May 10, 2026 at 6:22 pm

    Erm … How do you serialize? Usually, the XML serializer should never produce invalid XML.

    /EDIT in response to your update: Do not display invalid XML to your user to edit! Instead, display the properly escaped XML in the TextBox. Repairing broken XML isn’t fun and I actually see no reason not to display/edit the XML in a valid, escaped form.

    Again I could ask: how do you display the XML in the TextBox? You seem to intentionally unescape the XML at some point.

    /EDIT in response to your latest comment: Well yes, obviously, since the it can contain HTML. You need to escape your XML properly before writing it out into an HTML page. With that, I mean the whole XML. So this:

    <foo mean-attribute='&lt;'> 

    becomes this:

    &lt;foo mean-attribute='&amp;&lt;'&gt; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
i got an object with contents of html markup in it, for example: string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and

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.