title: Creating SVG fragments with Javascript and Strings
body: <p>I've seen several examples about how to use the DOM api to create SVG fragments from within Javascript, but I'm curious is there something I can use to create a SVG fragment from a string similar to innerHTML.  I've tried this following:</p>
  
  <pre><code>var svg = '&lt;foreignObject&gt;&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;p&gt;Hello World&lt;/p&gt;&lt;/foreignObject&gt;'
  var range = document.createRange();
  return range.createContextualFragment(svg);
  </code></pre>
  
  <p>Problem is createContextualFragment() with SVG blows up with an exception in Chrome.  So is there a cross browser way to do this?</p>