title: xpath replace [en-media] elements with [img]
body: <p>I need to find and replace in an Evernote xml file. It contains multiple entries like this:</p>
  
  <pre><code>&lt;en-media alt="Evernote Logo" hash="4914ced8925f9adcc1c58ab87813c81f" type="image/png"&gt;&lt;/en-media&gt;
  &lt;en-media alt="Evernote Logo" hash="4914dsd8925f9adcc1c58ab87813c81f" type="image/png"&gt;&lt;/en-media&gt;
  </code></pre>
  
  <p>with</p>
  
  <pre><code>&lt;img src="https://sandbox.evernote.com/shard/s1/res/143c8ad0-da92-4271-8410-651b88e8a2f1" height="something" width="something"/&gt;
  &lt;img src="https://sandbox.evernote.com/shard/s1/res/143c8233-da92-4271-8410-651b88e8a2f1" height="something" width="something"/&gt;
  </code></pre>
  
  <p>I'm doing this because Evernote's SDK admittedly lacks an easy way to show <em>both</em> textual and mime data (images, pdf's, etc.) in a single (or several easy) commands.</p>
  
  <p>Here is my attempt at a "find" but now I need the "replace":</p>
  
  <pre><code>$content=html_entity_decode($content); //content contains &amp;nbsp; and &amp;mdash; causing simplexml to complain
  $content=str_replace('&amp;',htmlentities('&amp;'),$content); //encode &amp; -- Lewis &amp; Clark
  
  $x = new SimpleXMLElement($content);
  $x = xpath('//en-media'); //find
  [?????] MYCODE_getLink(); //replace
  $content=$x-&gt;asXML(); //output
  $content=htmlentities($content); //put entities back
  </code></pre>