【发布时间】:2021-01-29 15:32:02
【问题描述】:
我的 XML 结构需要看起来像这样才能工作:
<yq1:ZwsCreateInfoRec xmlns:yq1="urn:test-com:document:test:soap:functions:mc-style">
<ItPrice>1337</ItPrices>
</yq1:ZwsCreateInfoRec>
为了尝试实现这一点,我正在使用这样的 SimpleXMLElement:
$xml = SimpleXMLElement('<yq1:ZwsCreteMaterialFrRef xmlns:yq1="urn:test-com:document:test:soap:functions:mc-style"></yq1:ZwsCreteMaterialFrRef>');
$xml->addChild('ItPrice', '1337');
当我现在运行 $xml->asXML() 时,它会显示这个(注意 ItPrice 节点上的命名空间):
<yq1:ZwsCreateInfoRec xmlns:yq1="urn:test-com:document:test:soap:functions:mc-style">
<yq1:ItPrice>1337</yq1:ItPrices>
</yq1:ZwsCreateInfoRec>
由于某种原因,如果我在子节点上有这样的命名空间,WebService 将无法工作,但如果我删除它们,它就可以工作。有没有办法让我删除它,还是我必须将它作为字符串循环并手动删除它们?
谢谢
【问题讨论】: