Forum Moderators: coopster

Message Too Old, No Replies

Is XSLTProcessor good for production site?

parsing xml with xsl

         

eltreno

4:51 pm on Jun 16, 2006 (gmt 0)

10+ Year Member



HI

I have just stumbled across this code (below) and really like coding xsl so figure I will use this rather then simpleXML to parse my XML to html using php5

Is this OK to use for a Live site?

What are the pros and cons?

I figure I will have this inside my php scripts where I want this content to appear (inside other php/html code, Not to produce a whole page, I think(not sure if that good practice?) just in planning stage now (it's for a bespoke cms I'm building)

Just seems to work fine etc, just want to make sure it's not a too good to be true thing becasue it makes my life easy

Also can you add php functions within the .xsl file or is that just pushing my luck!

$xml = new DOMDocument;
$xml->load("somexml.xml");

$xsl = new DOMDocument;
$xsl->load("somexsl.xsl");

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

echo $proc->transformToXML($xml);

coopster

1:13 am on Jun 18, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The DOM functions have been around longer than SimpleXML and I think you will find both a good set of tools for your arsenal. There are some good tutorials at zend.com on both feature sets.

eltreno

7:58 am on Jun 18, 2006 (gmt 0)

10+ Year Member



Yer I'm looking into the ones at zend there great

Thanks Coopster