Php/docs/xsltprocessor.transformtodoc

提供:Dev Guides
< Php
移動先:案内検索

XSLTProcessor::transformToDoc

(PHP 5, PHP 7)

XSLTProcessor::transformToDocDOMDocument に変換する


説明

public XSLTProcessor::transformToDoc ( object $document [, string|null $returnClass = null ] ) : DOMDocument|false

XSLTProcessor::importStylesheet() メソッドで与えられたスタイルシートを適用し、 ソースノードを DOMDocument に変換します。


パラメータ

document
変換されるノードを指定します。


返り値

結果の DOMDocument 。 エラーが発生した場合は false


例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!

参考