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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:34:06+00:00 2026-05-26T23:34:06+00:00

I have a trouble with a hand-writting XML. The XML is generated by concat

  • 0

I have a trouble with a hand-writting XML. The XML is generated by concat string as this :

            ReturnXML += "<agentchimique ";
            ReturnXML += "id_prod=\"" + Produit.Id + "\" ";
            ReturnXML += "nom_com_prod=\"" + Produit.NomComProd + "\" ";
            ReturnXML += "nom_four=\"" + Produit.Fournisseur.NomFour  + "\" ";
            ReturnXML += "PhraseR=\"" + Produit.PhrasesR.Replace( "<br/>", "@" ) + "\" ";
            ReturnXML += "PhraseS=\"" + Produit.PhrasesS.Replace( "<br/>", "@" ) + "\" ";
            ReturnXML += "numfds_prod=\"" + Produit.NumfdsProd.ToString() + "\" ";
            ReturnXML += "transverse_prod=\"" + Produit.TransverseProd.ToString() + "\" ";

This is only a few part of the whole XML and as you can see, all data is in attribute…
But some parameters as Produit.PhrasesR or Produit.PhrasesS can contains illegal character as < > or &.

This XML is stored as text in SQL and executed by SQL server, with the stored procedure sp_xml_preparedocument to be read in a report services.
This XML can be used too as data to generate as a webpage.

So, what is the quickest and easiest solution to resolve this encoding problem, as know I can not rewrite a true compliant XML (I don’t have any time for this), and this XML is used on many place in my project (replace character would be the easiest but it demand to replace back in reports and webpage).

Thanks for your helping.

  • 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-26T23:34:07+00:00Added an answer on May 26, 2026 at 11:34 pm

    You can use SecurityElement.Escape

    ReturnXML += "nom_four=\"" + SecurityElement.Escape(Produit.Fournisseur.NomFour) + "\" ";
    

    This will replace < with &lt;, > with &gt; etc.

    Although you really should use XDocument to build your xml correctly.

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

Sidebar

Related Questions

I have trouble using Perl grep() with a string that may contain chars that
I have trouble when designing classes like this class C1 { public: void foo();
I have trouble where, for some reason, SVN would only merge the newly generated
I have trouble finding way to correctly refactor this code so that there would
I'm having trouble finding a nice elegant ruby way to do this. I have
I have trouble comparing 2 double in Excel VBA suppose that I have the
I have trouble with the following piece of code. When I go through with
I have trouble defining a trigger for a MySQL database. I want to change
I have trouble accessing filestream via SqlFileStream. Sql server and IIS7 are on different
I have trouble launching Glassfish v3 on Mac In Windows, after installation of Glassfish

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.