Exemple 6-1: Lire un xml et un XSLT et renvoyer un document
$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);