2

PHP:

$new = new SimpleXMLElement('<g transform="matrix(8,-8,8,8,164,172)" preserveAspectRatio="none" >
    <defs>
        <g id="MyCircle" >
            <circle fill="#FFFFFF" cx="77" cy="131" r="9"/>
        </g>    
    </defs>
    <use  x="-101.5" y="-113.5" width="200" height="200" xlink:href="#MyCircle" />
</g>');

私は得ています:

警告: SimpleXMLElement::__construct(): 名前空間エラー: 使用中の href の名前空間プレフィックス xlink が定義されていません

4

1 に答える 1

2

xml<use>要素で名前空間を定義します。

$new = new SimpleXMLElement('<g transform="matrix(8,-8,8,8,164,172)" preserveAspectRatio="none" >
    <defs>
        <g id="MyCircle" >
            <circle fill="#FFFFFF" cx="77" cy="131" r="9"/>
        </g>    
    </defs>
    <use xmlns:xlink="http://www.w3.org/1999/xlink" x="-101.5" y="-113.5" width="200" 
         height="200" xlink:href="#MyCircle" />
</g>');
于 2013-04-26T01:46:53.907 に答える