MoFish Posted December 21, 2006 Share Posted December 21, 2006 hello. I have been using CF lately to develop my web-page; however, I have recently bought new hosting which no longer supports CF and uses PHP instead. i'm looking to convert the following code into PHP. could anyone assist me in doing so, it would be much appreciated. - the below code works perfect in CF, so i'm looking for the equivalent in php ;Dthanks alot, mofish.[code] <cfset MyXmlFile = Expandpath("MyXML.xml")> <cffile action="READ" variable="xmlInput" file="#MyXmlFile#"> <cfset MyXmlFile = Expandpath("Main.xsl")> <cffile action="READ" variable="xslInput" file="#MyXmlFile#"> <cfset xmlOutput = XMLTransform(xmlInput, xslInput)> <cfcontent type="text/html" reset="yes">[/code] Link to comment https://forums.phpfreaks.com/topic/31535-xml-convert-my-code-from-cf-to-php-small-code/ Share on other sites More sharing options...
trq Posted December 21, 2006 Share Posted December 21, 2006 Why dont you take a look at the [url=http://php.net/simplexml]simplexml[/url] extension. Link to comment https://forums.phpfreaks.com/topic/31535-xml-convert-my-code-from-cf-to-php-small-code/#findComment-146149 Share on other sites More sharing options...
MoFish Posted December 22, 2006 Author Share Posted December 22, 2006 thanks, ill have a read. from first glance it looks to be a total nightmare :( Link to comment https://forums.phpfreaks.com/topic/31535-xml-convert-my-code-from-cf-to-php-small-code/#findComment-146153 Share on other sites More sharing options...
trq Posted December 22, 2006 Share Posted December 22, 2006 Well its just that I dont think you'd find too many CF devs around here. Ive gotta say Ive never seen it much before, looks bloody awefull. Link to comment https://forums.phpfreaks.com/topic/31535-xml-convert-my-code-from-cf-to-php-small-code/#findComment-146157 Share on other sites More sharing options...
MoFish Posted December 22, 2006 Author Share Posted December 22, 2006 yeah it does, had a good old read through it there, and I think i'm gonna give it a miss :) cheers for your help anyways. Link to comment https://forums.phpfreaks.com/topic/31535-xml-convert-my-code-from-cf-to-php-small-code/#findComment-146167 Share on other sites More sharing options...
Barand Posted December 22, 2006 Share Posted December 22, 2006 I haven't seen CF code before but it looks like it's taking and XML file and applying XSL stylesheet to it.Try[code]<?php $xml = simplexml_load_file('MyXML.xml'); $xsl = simpleXML_load_file('Main.xsl'); $proc = new XsltProcessor(); $proc->importStylesheet($xsl); $newxml = $proc->transformToDoc($xml); print $newxml->saveXML();?>[/code] Link to comment https://forums.phpfreaks.com/topic/31535-xml-convert-my-code-from-cf-to-php-small-code/#findComment-146182 Share on other sites More sharing options...
MoFish Posted December 22, 2006 Author Share Posted December 22, 2006 [code]Warning: I/O warning : failed to load external entity "mainpage.xml" in /home/mo/public_html/mo/are2007/index.php on line 6Warning: I/O warning : failed to load external entity "are2007XML.xsl" in /home/mo/public_html/mo/are2007/index.php on line 7Fatal error: Class 'XsltProcessor' not found in /home/mo/public_html/mo/are2007/index.php on line 8[/code]oh dear, that didn't appear to go too great :D Link to comment https://forums.phpfreaks.com/topic/31535-xml-convert-my-code-from-cf-to-php-small-code/#findComment-146227 Share on other sites More sharing options...
Barand Posted December 22, 2006 Share Posted December 22, 2006 You'll need to enable the XSL extension Link to comment https://forums.phpfreaks.com/topic/31535-xml-convert-my-code-from-cf-to-php-small-code/#findComment-146313 Share on other sites More sharing options...
MoFish Posted December 22, 2006 Author Share Posted December 22, 2006 its now enabled, got my hosting to sort that out this morning. still a few errors however, but they should be errors in which I can be fixed... hopefully 8)[code]Warning: I/O warning : failed to load external entity "mainpage.xml" in /home/mo/public_html/mo/are2007/index.php on line 6Warning: I/O warning : failed to load external entity "are2007XML.xsl" in /home/mo/public_html/mo/are2007/index.php on line 7Warning: XSLTProcessor::importStylesheet() expects parameter 1 to be object, boolean given in /home/mo/public_html/mo/are2007/index.php on line 9Warning: XSLTProcessor::transformToDoc() expects parameter 1 to be object, boolean given in /home/mo/public_html/mo/are2007/index.php on line 10Fatal error: Call to a member function saveXML() on a non-object in /home/mo/public_html/mo/are2007/index.php on line 11[/code] Link to comment https://forums.phpfreaks.com/topic/31535-xml-convert-my-code-from-cf-to-php-small-code/#findComment-146394 Share on other sites More sharing options...
Barand Posted December 22, 2006 Share Posted December 22, 2006 Have you got the paths to the XML and XSL files defined correctly? Link to comment https://forums.phpfreaks.com/topic/31535-xml-convert-my-code-from-cf-to-php-small-code/#findComment-146578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.