I have a problem with SimpleXMLElement.
I have to create a XML as here:
<p:father>
<child></child>
</p:father>
If I try to do this with SimpleXMLElement result is:
<p:father>
<p:child></p:child>
</p:father>
So all children have the same namespace. PHP code is:
$xml = new SimpleXMLElement('<p:father xmlns:p="http://example.com" />');
$xml->addChild('child');
Can anyone help me? I have to do this in order to create xml for Eletronical Invoicing.
<child/>across all PHP versions, see 3v4l.org/lpt4g (But the warnings shown there already suggest that you are not currently handling creation of a namespaced element correctly to begin with.)