XSL XSLTProcessor::transformToDoc

(PHP 5, PHP 7, PHP 8)

XSLTProcessor::transformToDoc — DOMDocument로 변환


설명

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

XSLTProcessor::importStylesheet() 메서드에서 제공하는 스타일시트를 적용하여 소스 노드를 DOMDocument로 변환합니다.


매개변수

document
변환할 노드입니다.

반환 값

결과 DOMDocument 또는 오류 시 false입니다.


Examples

예제 #1 DOMDocument로 변환

                  
<?php

// Load the XML source
$xml = new DOMDocument;
$xml->load('collection.xml');

$xsl = new DOMDocument;
$xsl->load('collection.xsl');

// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules

echo trim($proc->transformToDoc($xml)->firstChild->wholeText);

?>
                  
                

위의 예는 다음을 출력합니다.

Hey! Welcome to Nicolas Eliaszewicz's sweet CD collection!
                

기타