array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'tr', ), 'this' => array ( 0 => 'xsltprocessor.transformtoxml.php', 1 => 'XSLTProcessor::transformToXML', ), 'up' => array ( 0 => 'class.xsltprocessor.php', 1 => 'XSLTProcessor', ), 'prev' => array ( 0 => 'xsltprocessor.transformtouri.php', 1 => 'XSLTProcessor::transformToUri', ), 'next' => array ( 0 => 'refs.ui.php', 1 => 'GUI Eklentileri', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'tr', 'path' => 'reference/xsl/xsltprocessor/transformtoxml.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
XSLTProcessor::transformToXML — Dönüşümü bir dizge olarak döndürür
xsltprocessor::importStylesheet() yöntemi ile belirtilen biçembendi belirtilen belgeye uygulayarak kaynak düğümünü bir dizgeye dönüştürüp döndürür.
Hata durumunda false
, aksi takdirde dönüşüm sonucunu bir dizge olarak
döndürür.
Örnek 1 - Bir dizgeye dönüşüm
<?php
// XML belgeyi yükleyelim
$xml = new DOMDocument;
$xml->load('collection.xml');
$xsl = new DOMDocument;
$xsl->load('collection.xsl');
// Dönüştürücüyü yapılandıralım
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // XSL kurallarını ekliyoruz
echo $proc->transformToXML($xml);
?>
Yukarıdaki örneğin çıktısı:
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>