XML - XSLT avec PHP

Depuis PHP5, inutile de se fatiguer, on peut produire des fichiers directement avec XML / XSL, exemple avec mon CV:

<?

# 2005, Daniel Schneider, TECFA for PHP 5's DOM functions

error_reporting(E_ALL);

$xml_file = 'cv.xml';
$xsl_file = 'cv.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);

?>

Mon CV en XML: http://www.akademia.ch/fr/acqui/cv.xml La xslt: http://www.akademia.ch/fr/acqui/cv.xsl Résultat avec ce fichier: http://www.akademia.ch/fr/acqui/cv.php5.php

 
info/xml_-_xslt_avec_php.txt · Dernière modification: 2008/11/11 11:37 (modification externe)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki