fork download
  1. <?php
  2.  
  3. $svgString = '<svg version="1.1" id="Слой_1" xmlns:x="&amp;ns_extend;" xmlns:i="&amp;ns_ai;" xmlns:graph="&amp;ns_graphs;" xmlns="http://w...content-available-to-author-only...3.org/2000/svg" xmlns:xlink="http://w...content-available-to-author-only...3.org/1999/xlink" x="0px" y="0px" width="225px" height="145px" viewBox="0 0 225 145" enable-background="new 0 0 225 145" xml:space="preserve">
  4. <g>
  5. <defs>
  6. <rect id="SVGID_1_" y="20.387" enable-background="new " width="225" height="104.225"></rect>
  7. </defs>
  8. <clipPath id="SVGID_2_">
  9. <use xlink:href="#SVGID_1_" overflow="visible"></use>
  10. </clipPath>
  11. </g>
  12. </svg>';
  13.  
  14. $svgObject = new SimpleXMLElement($svgString);
  15. print_r($svgObject->xpath("//rect"));
  16.  
  17. /* magic */
  18. $svgString = str_replace('xmlns=', 'ns=', $svgString);
  19. $svgObject = new SimpleXMLElement($svgString);
  20. print_r($svgObject->xpath('//rect'));
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
Array
(
)
Array
(
    [0] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [id] => SVGID_1_
                    [y] => 20.387
                    [enable-background] => new    
                    [width] => 225
                    [height] => 104.225
                )

        )

)