Transforming XML with XSL : XSLTProcessor « XML « PHP






Transforming XML with XSL

 
<?php
if (! extension_loaded ( "xsl" )) {
  dl ( "php_xsl.dll" );
}

$xslt = new xsltProcessor ( );
$xslt->importStyleSheet ( DomDocument::load ( 'data.xsl' ) );
$data = new DomDocument ( "1.0", "iso-8889-1" );
$data->preserveWhiteSpace = false;
$local_file = "data.xml";
$data->load ( 'http://data.org/data.xml' );
$fp = fopen ( $local_file, "wt" );
if ($fp) {
  fwrite ( $fp, $data->saveXML () );
  fclose ( $fp );
}
echo $xslt->transformToXML ( $data );
?>
  
  








Related examples in the same category

1.Load XML documents into a DOMDocument class and transform
2.Transforming XML to HTML with XSL
3.Transforming XML with XSLT and PHP functions