title: regex + replace character between tags using Notepad++
body: <p>I think using regex to find/replace is my best option for this.. but I'll give an overview of what I'm trying to do in case there is some other advice/suggestions</p>
  
  <ol>
  <li><p>I have a FLAT (static) .xml file</p></li>
  <li><p>I am converting things over to use a database instead of loading this flat .xml file, (this will be your usual form interface/GUI, that submits to a MySQL database using PHP/PDO (no SQL injections here buddy!) ;)  (this is already working fine)</p></li>
  <li><p>I am currently working on getting this 'back-log' of data from the flat .xml file into the database..</p>
  
  <p>a. I have tried to use <code>SQL LOAD XML INFILE</code>: <a href="https://stackoverflow.com/questions/22775206/how-to-use-load-xml-infile-with-special-characters">https://stackoverflow.com/questions/22775206/how-to-use-load-xml-infile-with-special-characters</a>  but couldn't figure out how to parse/escape special character data...</p>
  
  <p>b. I have now moved onto <code>PHP/SimpleXML</code>, but am finding trouble again with special characters in some of the nodes/elements in the XML.  (could be single or double quotes, '&amp;' sign, not sure.. its a 'description' field)</p></li>
  </ol>
  
  <p>When I try to load the XML file.. I get an error:</p>
  
  <blockquote>
    <p>Warning: simplexml_load_file() [function.simplexml-load-file]: xml_source.xml:142: parser error : Opening and ending tag mismatch: BR line 142 and description in C:\wamp\www\xml_tests\simpleXML_test.php on line 4</p>
  </blockquote>
  
  <p>If I find the xml node, and replace the apostrophe with <code>&amp;apos;</code> it will parse and move onto the next node that has a special character that breaks it.</p>
  
  <p>My gut instinct was try and find out how to use REGEX to search for any apostrophe (or any special character for that matter) between two tags....and do a replace before the data gets entered into the DB.</p>
  
  <p>But maybe there is a better way to parse through PHP/SimpleXML.. however it seems I need to get rid of this before SimpleXML will even read the file?</p>
  
  <pre><code>if(!$xml=simplexml_load_file('xml_source.xml')){
      trigger_error('Error reading XML file', E_USER_ERROR);
  }
  
  foreach($xml-&gt;entry as $entry){
      echo 'Name: ' . $entry-&gt;name . '&lt;br /&gt;';
      echo 'Date: ' . $entry-&gt;attributes()-&gt;date_entered . '&lt;br /&gt;';
  }
  </code></pre>
  
  <p>Simple test, but as mentioned I get the error above with the apostrophes still in there.</p>
  
  <p>How can I use REGEX to search for a special character (single quote/apostrophe) that is between two <code>&lt; tags &gt; &lt; /tags &gt;</code></p>
  
  <p>Here is the REGEX I have tried for the SEARCH part..(I cant seem to nail down the replace portion it replaces the whole word with the apostrophe for some reason?)</p>
  
  <p>Search: (Notepad++)</p>
  
  <pre><code>[?=&lt;description&gt;].'[?=&lt;/description&gt;]
  </code></pre>
  
  <p>Replace:</p>
  
  <pre><code>\&amp;apos;
  </code></pre>
  
  <p>example of XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;entries&gt;
      &lt;entry submissionDate="2013-02-18"&gt;
          &lt;fontName&gt;String/Text&lt;/fontName&gt;    
          &lt;fontCreator&gt;String/Text&lt;/fontCreator&gt;
          &lt;fontFormat&gt;String/Text&lt;/fontFormat&gt;
          &lt;optimized&gt;String/Text&lt;/optimized&gt;
          &lt;fontPrice&gt;Nuumber/Int (with decimal)&lt;/fontPrice&gt;
          &lt;fontImage&gt;String/Text&lt;/fontImage&gt;
          &lt;fontURL&gt;Int&lt;/fontURL&gt;
          &lt;description&gt;Don't can't lot's of 'single' quote/apostrophes and "double quotes" too&lt;/description&gt;
          &lt;piracyVid&gt;String/Text&lt;/piracyVid&gt;
          &lt;demoLink&gt;String/Text&lt;/demoLink&gt;
      &lt;/entry&gt;
  
      &lt;entry submissionDate="2013-02-18"&gt;
          &lt;fontName&gt;String/Text&lt;/fontName&gt;    
          &lt;fontCreator&gt;String/Text&lt;/fontCreator&gt;
          &lt;fontFormat&gt;String/Text&lt;/fontFormat&gt;
          &lt;optimized&gt;String/Text&lt;/optimized&gt;
          &lt;fontPrice&gt;Nuumber/Int (with decimal)&lt;/fontPrice&gt;
          &lt;fontImage&gt;String/Text&lt;/fontImage&gt;
          &lt;fontURL&gt;Int&lt;/fontURL&gt;
          &lt;description&gt;Don't can't lot's of 'single' quote/apostrophes and "double quotes" too&lt;/description&gt;
          &lt;piracyVid&gt;String/Text&lt;/piracyVid&gt;
          &lt;demoLink&gt;String/Text&lt;/demoLink&gt;
      &lt;/entry&gt;
  &lt;/entries&gt;
  </code></pre>
  
  <p>Thanks</p>