在php代码生成的xml文件中导入外部dtd

时间:2014-12-19 18:13:21

标签: php xml external dtd

我有这个代码,它从存储在db中的数据生成一个xml文件。我想制作由此代码生成的xml导入外部dtd文件

$connessione = mysql_connect("localhost", "privatedigitallibrary1", "") or die("problemi connessione");
mysql_select_db("my_privatedigitallibrary1", $connessione) or die("problemi database");                 
extract( $_GET );       
$query = " SELECT * FROM schede WHERE codiceScheda = '$codiceScheda' ";

$result = mysql_query($query) or die("problemi query");     
$row = mysql_fetch_array($result);  


$domtree = new DOMDocument('1.0', 'UTF-8');


$domtree->formatOutput = true;
$domtree->preserveWhiteSpace = false;

$xmlRoot = $domtree->createElement("scheda");
$xmlRoot = $domtree->appendChild($xmlRoot);

$xmlRoot->appendChild($domtree->createElement('autoreScheda', $row['autoreScheda']));
$xmlRoot->appendChild($domtree->createElement('dataCompilazione', $row['dataScheda']));
$xmlRoot->appendChild($domtree->createElement('tipoDocumento', $row['tipoDocumento']));
$xmlRoot->appendChild($domtree->createElement('paroleChiave', $row['parolaChiave1'].", ".$row['parolaChiave2'].", ".$row['parolaChiave3']));

$xmlRoot->appendChild($domtree->createElement('autoreDocumento', $row['autore']));
$xmlRoot->appendChild($domtree->createElement('titoloDocumento', $row['titolo']));
$xmlRoot->appendChild($domtree->createElement('annoDocumento', $row['anno']));   
$xmlRoot->appendChild($domtree->createElement('url', $row['url']));
$xmlRoot->appendChild($domtree->createElement('commento', $row['commento']));



$domtree->save('schede/xml_cod'.$codiceScheda.'.xml');

header('Content-disposition: attachment; filename=xml_cod'.$codiceScheda.'.xml');
header("Content-type: application/xml");
readfile('schede/xml_cod'.$codiceScheda.'.xml');

0 个答案:

没有答案