title: Easiest way to replace illegal character in XML attributes
body: <p>I have a trouble with a hand-writting XML. The XML is generated by concat string as this :</p>
  
  <pre><code>            ReturnXML += "&lt;agentchimique ";
              ReturnXML += "id_prod=\"" + Produit.Id + "\" ";
              ReturnXML += "nom_com_prod=\"" + Produit.NomComProd + "\" ";
              ReturnXML += "nom_four=\"" + Produit.Fournisseur.NomFour  + "\" ";
              ReturnXML += "PhraseR=\"" + Produit.PhrasesR.Replace( "&lt;br/&gt;", "@" ) + "\" ";
              ReturnXML += "PhraseS=\"" + Produit.PhrasesS.Replace( "&lt;br/&gt;", "@" ) + "\" ";
              ReturnXML += "numfds_prod=\"" + Produit.NumfdsProd.ToString() + "\" ";
              ReturnXML += "transverse_prod=\"" + Produit.TransverseProd.ToString() + "\" ";
  </code></pre>
  
  <p>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 &lt; > or &amp;.</p>
  
  <p>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.</p>
  
  <p>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).</p>
  
  <p>Thanks for your helping.</p>