0

I have been trying to loop the svg element but not getting array values. with the link referenced Loop through SVG elements with PHP

SVG CODE:

$item['svg'] = '<svg width="219" height="109" viewBox="0 0 219 109" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="0.6491990578360856">
<text fill="#000000" stroke="none" stroke-width="0" stroke-linecap="round" stroke-linejoin="round" x="65" y="85" text-anchor="middle" font-size="90.75" font-family="Twine" data-textcurve="0" data-itemzoom="1 1"><tspan dy="0" x="49%">Hello</tspan></text>
</g></svg>';


   $svg = new SimpleXMLElement( $item['svg'] );

    // register the default namespace
    $svg->registerXPathNamespace('svg', 'http://www.w3.org/2000/svg');
    // required for the <image xlink:href=" ... attribute
    $svg->registerXPathNamespace('xlink', 'http://www.w3.org/1999/xlink');

    // use the prefixes in the query
    $result = $svg->xpath('//svg:text/@xlink:href');

    print_r($result);

        for ($i = 0; $i < count($result); $i++)
            {

            }
gopi
  • 11
  • 3

0 Answers0