2012-11-12 14 views
5

Ho esportato un file XML in PHP utilizzando:Come aggiungere DOCTYPE in export xml?

$xmldoc = new DOMDocument();   
$xmldoc->formatOutput = true; 
$xmldoc->encoding="Shift_JIS"; 

// create root nodes 
$root = $xmldoc->createElement("TableData"); 
$xmldoc->appendChild($root); 
$xmldoc->save($filename); 

Risultato:

<?xml version="1.0" encoding="Shift_JIS"?> 
<TableData> </TableData> 

Ora, voglio aggiungere fila <!DOCTYPE TableDef SYSTEM "TableData.dtd"> come:

<?xml version="1.0" encoding="Shift_JIS"?> 
    <!DOCTYPE TableDef SYSTEM "TableData.dtd"> 
    <TableData> </TableData> 

Come aggiungere DOCTYPE in un xml esportato? Grazie.

+0

Controllare [DOMImplementation :: createDocumentType] (http://www.php.net/manual/en/domimplementation.createdocumenttype.php) – air4x

+0

http://pointbeing.net/weblog/2009/03/adding- a-doctype-dichiarazione-a-un-DOMDocument-in-php.html – Adam

risposta