I'm working on DomDocument
to build my XML. I need to output this header:
<p:FatturaElettronica versione="FPR12" xsi:schemaLocation="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2 http://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2/Schema_del_file_xml_FatturaPA_versione_1.2.xsd">
To achieve this result I have written this code:
$dom = new \DomDocument("1.0", "UTF-8");
$init = $dom->createElementNS('http://www.example.com/XFoo', 'p:FatturaElettronica');
$init->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$init->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation', 'http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2 http://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2/Schema_del_file_xml_FatturaPA_versione_1.2.xsd');
$version = "FPR12";
$init->appendChild($dom->createAttribute('versione'))->appendChild($dom->createTextNode($version));
But the output is this:
<p:FatturaElettronica xmlns:p="http://www.example.com/XFoo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ivaservizi.agenziaentrate.gov.it/docs/xsd
/fatture/v1.2 http://www.fatturapa.gov.it/export/fatturazione
/sdi/fatturapa/v1.2/Schema_del_file_xml_FatturaPA_versione_1.2.xsd"
versione="FPR12">
Where am I wrong?