Unable to add Attribute with Namespace Prefix using PHP Simplexml

北战南征 提交于 2019-11-29 07:55:43
user988201

If you want to add an attribute with a specific namespace prefix w/o adding the namespace to the document, you have to specify not only the prefix in the name parameter, but also prefix it again with xmlns, in my example: xmlns:ss:Type. The namespace URI (third parameter) then will be ignored as well, so it is not necessary either:

$data->addAttribute("xmlns:ss:Type", "String");

Note the xmlns: in front of ss:Type. The output then is as required:

<Cell><Data ss:Type="String">value</Data></Cell>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!