note 85390 deleted from function.xslt-create by sobak

From: Date: Thu, 24 Nov 2016 11:52:58 +0000
Subject: note 85390 deleted from function.xslt-create by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207553@lists.php.net to get a copy of this message
Note Submitter: LW ---- Hello, I changed the function from myadzel (?) a little bit, so that it now correctly uses either a file OR a string as parameter - WITHOUT producing PHP warnings. See here: <?php function xslt ($xml, $xsl) { $xh = @xslt_create(); $args['xml'] = ( file_exists( $xml ) )?join ('', file ($xml)):$xml; $args['xsl'] = ( file_exists( $xsl ) )?join ('', file ($xsl)):$xsl; // try with a string $result = @xslt_process ($xh, 'arg:/xml', 'arg:/xsl', NULL, $args); // try with resource if (!$result) { $result = @xslt_process ($xh, $xml, $xsl); } @xslt_free ($xh); return $result; } ?> Examples: echo xslt ('./index.xml', './index.xsl'); echo xslt ('<test><example>An example!</example></test>', './index.xsl');

« previous php.notes (#207553) next »