PREVIOUS UP   Technologies Internet et Education, © TECFA
  7. XSLT avec DOM

7. XSLT avec DOM

Attention: Dans le manuel PHP il faut consulter la section XSL

(en non pas XSLT qui n'existe plus dans PHP 5 !)

 
$xml_file = 'programme.xml';
$xsl_file = 'programme.xsl';
 
// load the xml file (and test first if it exists)
$dom_object = new DomDocument();
if (!file_exists($xml_file)) exit('Failed to open $xml_file');
$dom_object->load($xml_file);
 
// create dom object for the XSL stylesheet and configure the transformer
$xsl_obj = new DomDocument();
if (!file_exists($xsl_file)) exit('Failed to open $xsl_file');
$xsl_obj->load($xsl_file);
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl_obj);
 // attach the xsl rules
 
$html_fragment = $proc->transformToXML
($dom_object);
print ($html_fragment);
// Note: il faudrait voir comment insérer des directives XSLT

PREVIOUS UP -- TIE