0
我对XML,命名空间和PHP DOM有一些问题。使用php生成xml命名空间
这是我的输出,我应该得到:
<cd:Document xmlns="http://www.zbs-giz.si/Schemas/2006/ZBSxml/2.2" xmlns:cd="http://www.crea.si/Schemas/2004/Document/ZBSxml/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.crea.si/Schemas/2004/Document/ZBSxml/2.0/ZbsCreaDoc.xsd">
<cd:Data>
<cd:DataFormat>
<cd:MimeType>text/xml</cd:MimeType>
</cd:DataFormat>
<cd:Content>
<cd:EmbeddedData>
,这是我的PHP代码
$root = $doc->appendChild($doc->createElementNS('http://www.zbs-giz.si/Schemas/2006/ZBSxml/2.2', 'cd:Document'));
$root->setAttributeNS('http://www.zbs-giz.si/Schemas/2006/ZBSxml/2.2', 'cd', 'http://www.crea.si/Schemas/2004/Document/ZBSxml/2.0');
$root->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', 'http://www.crea.si/Schemas/2004/Document/ZBSxml/2.0/ZbsCreaDoc.xsd');
任何想法如何解决这个问题?