PHP 5.4.33 Released

XSLTProcessor::__construct

(PHP 5)

XSLTProcessor::__constructCreates a new XSLTProcessor object

Descrierea

XSLTProcessor::__construct ( void )

Creates a new XSLTProcessor object.

Parametri

Această funcție nu are parametri.

Valorile întoarse

Nu este întoarsă nici o valoare.

Exemple

Example #1 Creating an XSLTProcessor

<?php

$doc 
= new DOMDocument();
$xsl = new XSLTProcessor();

$doc->load($xsl_filename);
$xsl->importStyleSheet($doc);

$doc->load($xml_filename);
echo 
$xsl->transformToXML($doc);

?>

add a note add a note

User Contributed Notes 1 note

up
1
Martin
5 years ago
The example above is a bit confusing because it uses the same variable ($doc) for two different things. I would rather write

<?php

$xsl
= new XSLTProcessor();
$xsldoc = new DOMDocument();
$xsldoc->load($xsl_filename);
$xsl->importStyleSheet($xsldoc);

$xmldoc = new DOMDocument();
$xmldoc->load($xml_filename);
echo
$xsl->transformToXML($xmldoc);

?>

[ Editor's note - thiago AT php DOT net: This note has improvements from Matthieu ]
To Top