XSLTProcessor::transformToDoc
(PHP 5, PHP 7)
XSLTProcessor::transformToDoc — DOMDocument に変換する
説明
public XSLTProcessor::transformToDoc
( object $document
[, string|null $returnClass
= null
] ) : DOMDocument|false
XSLTProcessor::importStylesheet() メソッドで与えられたスタイルシートを適用し、 ソースノードを DOMDocument に変換します。
パラメータ
document
- 変換されるノードを指定します。
例
例1 DOMDocument への変換
<?php// XML ソースをロードする$xml = new DOMDocument;$xml->load('collection.xml');$xsl = new DOMDocument;$xsl->load('collection.xsl');// 変換の設定を行う$proc = new XSLTProcessor;$proc->importStyleSheet($xsl); // XSL ルールを適用するecho trim($proc->transformToDoc($xml)->firstChild->wholeText);?>
上の例の出力は以下となります。
Hey! Welcome to Nicolas Eliaszewicz's sweet CD collection!