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():namespace error:未定义使用的href的命名空间前缀xlink
答案 0 :(得分: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>');