When you embed SVG within html namespaces are optional when you reference a file where the svg node is the root then they are not.
You are missing the SVG namespace in your encoded data i.e. you need
xmlns="http://www.w3.org/2000/svg"
on the root node.
Your example works for me with that change.