XSLTProcessor::transformToXML
(PHP 5)
XSLTProcessor::transformToXML — Transforma a XML
Descripción
Transforma el nodo origen a un string aplicando la hoja de estilos dada por el método xsltprocessor::importStylesheet().
Parámetros
-
doc -
El documento transformado.
Valores devueltos
Resultado de la transformación a string o FALSE en caso de error.
Ejemplos
Ejemplo #1 Transformando a un string
<?php
// Carga el fichero XML origen
$xml = new DOMDocument;
$xml->load('collection.xml');
$xsl = new DOMDocument;
$xsl->load('collection.xsl');
// Configura el procesador
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // adjunta las reglas XSL
echo $proc->transformToXML($xml);
?>
El resultado del ejemplo sería:
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>
Ver también
- XSLTProcessor::transformToDoc() - Transforma en un DOMDocument
- XSLTProcessor::transformToUri() - Transformar a URI