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 回答