info:xml_-_xslt_avec_php

Action disabled: source

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://radeff.red/fr/acqui/cv.xml La xslt: http://radeff.red/fr/acqui/cv.xsl Résultat avec ce fichier: http://radeff.red/fr/acqui/cv.php5.php

  • info/xml_-_xslt_avec_php.txt
  • Dernière modification : 2018/07/18 09:46
  • de radeff