XSL XSLTProcessor::transformToXml
(PHP 5, PHP 7, PHP 8)
XSLTProcessor::transformToXml — XML로 변환
설명
public XSLTProcessor::transformToXml(object $document
): string|null|false
소스 노드를 xsltprocessor::importStylesheet() 메서드에서 제공하는 스타일시트를 적용하는 문자열로 변환합니다.
매개변수
document
- 변환할 DOMDocument 또는 SimpleXMLElement 개체입니다.
반환 값
변환 결과는 문자열이거나 오류 시 false
입니다.
Examples
예제 #1 문자열로 변환
<?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 $proc->transformToXML($xml);
?>
위의 예는 다음을 출력합니다.
Hey! Welcome to Nicolas Eliaszewicz's sweet CD collection! <h1>Fight for your mind</h1><h2>by Ben Harper - 1995</h2><hr> <h1>Electric Ladyland</h1><h2>by Jimi Hendrix - 1997</h2><hr>
기타
- XSLTProcessor::transformToDoc() - DOMDocument로 변환
- XSLTProcessor::transformToUri() - URI로 변환