daemonreaver Posted May 8, 2007 Share Posted May 8, 2007 A simple project for a site has turned into a week-long quest to parse an XML file... I *could* use my old XML include, yes, but I'd really like to use the XSL style sheets. All I would like to do is grab the shoutcast XML data and apply an XSL sheet to it and include the resulting HTML in a page. Simple, aye? Well, I have been trying over and over to get either XSL or XSLT to work, and have come up with zilch. Either expat 2+sablot doesn't work with libxslt in PHP 5, or something is just not working at all with it, so I tried XSL. I managed to get *somewhere* with it, but it barfs when I use the example class from the manual: class XSLTProcessor { DOMDocument transformToDoc(DOMNode $doc) } $xml = new DOMDocument; $xml->load('sample.xml'); $xsl = new DOMDocument; $xsl->load('sample.xsl'); $proc = new XSLTProcessor; $proc->importStyleSheet($xsl); echo trim($proc->transformToDoc($xml)->firstChild->wholeText); Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in \sample.php on line 11 I honestly don't mess with classes, not having any need to turn simple functions into objects, so if anyone would happen to have some ideas here, I'd be happy to give it a try. Not sure if I can post a link to the "test" page(s) here, but if anyone needs I can. PHP 5, Win32. Issue 1: XSLT just does not register in phpinfo(), regardless of what site's instructions I use. (I have never had an issue dropping an extension in, this is the first time I couldn't get one to work at all.) Issue 2: (lib)XSL's doc just aren't all that friendly in how to create the class to call. Quote Link to comment https://forums.phpfreaks.com/topic/50443-xslxslt-issues/ Share on other sites More sharing options...
daemonreaver Posted May 8, 2007 Author Share Posted May 8, 2007 Again, found yet another site on how to install XSLT, and after chasing down iconv.dll v1.9.0, it still will not show in phpinfo() output. I have the latest expat.dll (even tried renaming it to "expat.dll" from "libexpat.dll"), and php_xslt.dll is in the ext folder and uncommented. Usually that's all I have to do. What's the trick here? iconv.dll, expat.dll, libexpat.dll, and sablot.dll are in both the PHP folder and system32 (WinXP test machine). Beyond that, I have no idea what' s going on. No startup errors from PHP, it just doesn't use php_xslt.dll at all it seems. Anyone have any suggestions on how to get this to work? Seems an awful lot of trouble just to get basic XML files to use XSL to HTML ... Quote Link to comment https://forums.phpfreaks.com/topic/50443-xslxslt-issues/#findComment-247882 Share on other sites More sharing options...
Barand Posted May 8, 2007 Share Posted May 8, 2007 I've used this successfully <?php $xml = simpleXML_load_file('newsfeed.xml'); $xsl = simpleXML_load_file('newsfeed.xsl'); $proc = new XsltProcessor(); $proc->importStylesheet($xsl); $newxml = $proc->transformToDoc($xml); print $newxml->saveXML(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/50443-xslxslt-issues/#findComment-247890 Share on other sites More sharing options...
daemonreaver Posted May 8, 2007 Author Share Posted May 8, 2007 Well, if XsltProcessor() was defined somewhere, it might work for me as well. It appears that the XSL/XSLT extensions for PHP 5.1 are broken. Here's the error log output (after turning log to File on), which is quite disappointing. [08-May-2007 06:54:50] PHP Warning: PHP Startup: Unable to load dynamic library './ext\php_xslt.dll' - The specified module could not be found. in Unknown on line 0 [08-May-2007 06:54:50] PHP Warning: PHP Startup: Unable to load dynamic library './ext\php_xsl.dll' - The specified procedure could not be found. in Unknown on line 0 Seems I will end up using a manual parser include for XML. Quote Link to comment https://forums.phpfreaks.com/topic/50443-xslxslt-issues/#findComment-247901 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.