title: Use Powershell to replace characters within a specific string
body: <p>I'm using a Powershell script to automate the replacement of some troublesome characters from an xml file such as &amp; ' - £ </p>
  
  <p>The script I have works well for these characters, but I also want to remove the double quote character " but only if it is used within an xml attribute (which unfortunately is enclosed by double quotes) so I obviously cannot remove all double quotes from the xml file as this will stop the attributes from working as they should.</p>
  
  <p>My Powershell script is below:</p>
  
  <pre><code>(Get-Content C:\test\communication.xml) | 
  Foreach-Object {$_ -replace "&amp;", "+" -replace "£", "GBP" -replace "'", "" -replace "–", " "} |
  Set-Content C:\test\communication.xml
  </code></pre>
  
  <p>What I'd like to be able to so is to remove ONLY the double quotes that make up part the XML attributes that are themselves enclosed by a pair of double quotes as below.
  I know that Powershell looks at each line as a separate object so suspect this should be quite easy, possibly by using conditions?</p>
  
  <p>An example XML file is below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Portal&gt; 
  &lt;communication updates="Text data with no double quotes in the attribute" /&gt;
  &lt;communication updates="Text data that "includes" double quotes within the double quotes for the attribute" /&gt;
  &lt;/Portal&gt;
  </code></pre>
  
  <p>In the above example I'd like to remove only the double quotes that immediately surround the word includes BUT not the double quotes that are to the left of the word Text or to the right of the word attribute.
  The words used for the XML attributes will change on a regular basis but the left double quote will always be to the immediate right of the = symbol and the right double quote will always be to the left of a space forward slash combination /
  Thanks </p>