title: Decoding base64 images in XML file with PHP
body: <p>I'm trying to get product images from a proprietary ERP system into OpenCart. </p>
  
  <p>So far (with the help of another answer on Stack Overflow) I have been able to save the images in separate files with this code:
  <a href="http://pastebin.com/gv6M8QPT" rel="nofollow">http://pastebin.com/gv6M8QPT</a></p>
  
  <p>A sample XML file looks like this:
  <a href="http://pastebin.com/k6Eq4Rpr" rel="nofollow">http://pastebin.com/k6Eq4Rpr</a></p>
  
  <p>There are 3 tags:</p>
  
  <ul>
  <li>id: in this case "1000" </li>
  <li>filename: in this case "sampleimage.jpg"</li>
  <li>mediablob: which is bin.base64 encoded image</li>
  </ul>
  
  <p>Instead of simply saving the XML files I would now like to do the following:</p>
  
  <ol>
  <li>Convert the mediablob in the XML file to the binary image file</li>
  <li>Save the image file as <code>&lt;id&gt;.jpg</code> - where <code>jpg</code> is created based on the extention used in <code>&lt;filename&gt;</code> tag. </li>
  </ol>