I have an XML structure that needs to look like this to work:
<yq1:ZwsCreateInfoRec xmlns:yq1="urn:test-com:document:test:soap:functions:mc-style">
<ItPrice>1337</ItPrices>
</yq1:ZwsCreateInfoRec>
To try and achieve this I'm using SimpleXMLElement like this:
$xml = SimpleXMLElement('<yq1:ZwsCreteMaterialFrRef xmlns:yq1="urn:test-com:document:test:soap:functions:mc-style"></yq1:ZwsCreteMaterialFrRef>');
$xml->addChild('ItPrice', '1337');
When I now run $xml->asXML()
it shows me this (Note the namespace on the ItPrice node):
<yq1:ZwsCreateInfoRec xmlns:yq1="urn:test-com:document:test:soap:functions:mc-style">
<yq1:ItPrice>1337</yq1:ItPrices>
</yq1:ZwsCreateInfoRec>
For some reason the WebService doesn't work if I have the namespace on the child nodes like that but if I remove them it works. Is there a way for me to remove this or do I have to loop through this as a string and remove them manually?
Thanks
question from:
https://stackoverflow.com/questions/65950150/how-to-remove-namespace-with-php-simplexmlelement 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…