Forum Moderators: coopster

Message Too Old, No Replies

PHP equivalent of this ASP code?

Load XML -> Load XSL -> Transform to Xhtml

         

Darkelve

9:03 am on Jul 26, 2006 (gmt 0)

10+ Year Member



I'm using the code below on a website to create a small 'news' block. Basically the news 'content' (description, link information, ...) is contained inside an XML file, on which I use XSLT to transform it into an xhtml block (with as result: the 'news' block [div id="news"] on the page).

How can I do this in PHP? At least, what functions should I look into? The XML and XSLT are already written.

And is the transformation (PHP code) comparable to this (ASP code), or does PHP use an entirely different method to obtain this result?

I'm only starting out with PHP programming, decided it would be a better use of my time (and money...) than learning more ASP. Right now I need this code to complete the transition from ASP scripting to PHP scripting for a large number of pages on my website.


<%

'Load XML set xml = Server.CreateObject("Microsoft.XMLDOM") xml.async = false xml.load(Server.MapPath("news.xml"))

'Load XSL set xsl = Server.CreateObject("Microsoft.XMLDOM") xsl.async = false xsl.load(Server.MapPath("news.xsl"))

'Transform file Response.Write(xml.transformNode(xsl)) %>

[edited by: Darkelve at 9:03 am (utc) on July 26, 2006]

eelixduppy

1:49 pm on Jul 26, 2006 (gmt 0)



If you have PHP 5, you may be able to accomplish your task with SimpleXML [us2.php.net]. I would take a look there, and also at other XML related functions at [php.net...]

Good luck!

Darkelve

1:55 pm on Jul 27, 2006 (gmt 0)

10+ Year Member



The problem is if this is not already installed, this is on a shared hosting account so I'm not able to install anything not already part of the PHP installation.

But yes, I do believe PHP5 is installed.