qwerty234 Posted September 11, 2007 Share Posted September 11, 2007 I cannot get the following XSLT to work. I am grabbing the feed properly but the HTML and the XML elements that are supposed to fill it are not being displayed at all. Can some one please help / debug my code? Code follows below. I have the following code that successfully grabs an XML feed: <?php $detailsObtained = false; $syms = ""; $serviceURL = "http://localhost:8880/detailed_quote.html.xml"; $cobj=curl_init($serviceURL); curl_setopt($cobj,CURLOPT_RETURNTRANSFER,1); $response=curl_exec($cobj); curl_close($cobj); if ($response) { $detailsObtained = true; } else echo "Error reading feed"; if ($detailsObtained) { $parser = xslt_create(); $html = xslt_process($parser,$response,"/var/www/html/transform.xsl"); echo($html); } ?> My XSL looks like this: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>Stocks</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="left">Ticker</th> <th align="left">high</th> </tr> <xsl:for-each select="MSXML/quote"> <tr> <td><xsl:value-of select="ticker" /></td> <td><xsl:value-of select="high" /></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> And the abbreviated XML feed (which I cannot change the format of) and will have to stay as is looks like the following: <MSXML> <quote source="MSFT"> <ticker>MSFT</ticker> <description>MICROSOFT CORP.</description> <current>28.54</current> <netChange>+0.10</netChange> <percentChange>+0.35%</percentChange> <open>28.67</open> <high>28.75</high> <low>28.41</low> <close>28.44</close> <oneYearHigh>31.84</oneYearHigh> <oneYearLow>25.42</oneYearLow> <dateTime>09/10/2007 14:14 EDT</dateTime> </quote> <quote source="SPX.X"> <ticker>SPX.X</ticker> . . . </MSXML> Link to comment https://forums.phpfreaks.com/topic/68787-need-help-with-an-xslt/ Share on other sites More sharing options...
effigy Posted September 11, 2007 Share Posted September 11, 2007 This works OK for me outside of PHP. What kind of errors are you getting? Link to comment https://forums.phpfreaks.com/topic/68787-need-help-with-an-xslt/#findComment-346028 Share on other sites More sharing options...
Barand Posted September 11, 2007 Share Posted September 11, 2007 Another way is to create a "data island" <xml src="tktquote.xml" id="quote" async="false"> </xml> <table datasrc="#quote" width="50%" border="1"> <thead> <th>Description</th> <th>High</th> </thead> <tr align="left"> <td><div datafld="description"></div></td> <td><div datafld="high"></div></td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/68787-need-help-with-an-xslt/#findComment-346259 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.