<?php
$root = new SimpleXMLElement('<xml/>');
$child=$root->addChild('UDF:VATDEALERNATURE.LIST',' ');
$child->addAttribute('xmlns:UDF','`VATDealerNature`');
$child->addAttribute('ISLIST','YES');
$child_1 = $child->addChild('UDF:VATDEALERNATURE','xyzzzzz');
$child_1->addAttribute('DESC','`VATDealerNature`');
header('Content-type: text/xml');
echo $root->asXML();
我使用SimpleXMLElement()函数将php用于xml。 这是一个实际的结果是:
<xml>
<VATDEALERNATURE.LIST UDF="`VATDealerNature`" ISLIST="YES">
<VATDEALERNATURE DESC="`VATDealerNature`">xyzzzzz</VATDEALERNATURE>
</VATDEALERNATURE.LIST>
</xml>
我希望此结果添加标记冒号并添加属性冒号
<xml>
<UDF:VATDEALERNATURE.LIST xmlns:UDF="`VATDealerNature`" ISLIST="YES">
<UDF:VATDEALERNATURE DESC="`VATDealerNature`">xyzzzzz</UDF:VATDEALERNATURE >
</UDF:VATDEALERNATURE.LIST>
</xml>