I am attempting to add an XML attribute with PHP that contains a colon.
I want it to look like this:
<record xsi:schemaLocation="http://abc.com/abcItem file:///somename.xsd">
I attempted to add the attribute like this:
$record_xml->addAttribute('xsi:schemaLocation','http://abc.com file:///somepath/somename.xsd');
but the resulting XML is:
<record schemaLocation="http://abc.com/abcItem file:///somepath/somename.xsd">
In addition to the namespace prefix (the part before the colon), you must also include the corresponding namespace URI (as the third argument):
$record_xml->addAttribute(
'xsi:schemaLocation',
'http://abc.com file:///somepath/somename.xsd',
'http://www.w3.org/2001/XMLSchema-instance'
);