XSLTProcessor
在线手册:中文 英文
PHP手册

XSLTProcessor::__construct

(PHP 5)

XSLTProcessor::__constructCreates a new XSLTProcessor object

说明

XSLTProcessor::__construct() ( void )

Creates a new XSLTProcessor object.

参数

此函数没有参数。

返回值

没有返回值。

范例

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);

?>


XSLTProcessor
在线手册:中文 英文
PHP手册
PHP手册 - N: Creates a new XSLTProcessor object

用户评论:

Martin (04-Jun-2009 11:02)

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 ]