0

The contents of SVG file:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
 width="120px" height="120px" viewBox="0 0 120 120" style="enable-background:new 0 0 120 120;" xml:space="preserve">
...
</svg>

Currently I am using file_get_contents(), but that also includes <?xml ...> header. How do I include only the svg tag and also strip some attributes (id, xmlns, xmlns:xlink, xml:space) from it? So the result would be like

<svg version="1.1" x="0px" y="0px" width="120px" height="120px" viewBox="0 0 120 120" style="enable-background:new 0 0 120 120;">
...
</svg>
igrynsh
  • 3
  • 2
  • In that case every question regarding XML parsing is duplicate. All I would like to see is just a simple example which I couldn't find. I am just trying to figure out the best approach. I tried using simple PHP functions like `substr()` to get only the part after "asXML()` the header and even the comment was there. – igrynsh Sep 29 '15 at 10:29
  • Stripping `xmlns="http://www.w3.org/2000/svg"` removes the namespace. As an XML file it is not SVG any more. – ThW Sep 29 '15 at 15:09
  • I suppose I don't need it if I simply include it inline in HTML5. Like you can see [here](http://www.w3schools.com/svg/svg_inhtml.asp) – igrynsh Sep 29 '15 at 17:27

0 Answers0