title: How can I make my xml safe for parsing (when it has & character in it)?
body: <p>I've been given an xml string which I need to put through a parser.  Its currently complaining because of an illegal xml character.  Very simplified example:</p>
  
  <pre><code>&lt;someXml&gt;this &amp; that&lt;/someXml&gt;
  </code></pre>
  
  <p>I know that the solution is to replace <code>&amp;</code> with <code>&amp;amp;</code>, but I'm not generating the XML and therefore have no control over the values.  </p>
  
  <p>A simple string replace is not the right way to to this since the '&amp;' has special meaning in XML and a global replace of '&amp;' with '&amp;amp;' would ruin the special meaning which was intended.  Is there a solution to take a full xml document and 'fix' it so that '&amp;' become '&amp;amp;', but only where intended?  Am I safe to globally replace ' &amp; ' with ' &amp;amp; ' (note the spaces on either side)?</p>