Forum Moderators: coopster
I found [uk.php.net...]
which looks like a start, but the error returned is
Fatal error: Cannot instantiate non-existent class: domdocument in ...
which I guess means that XML support isn't part of of the version of php on my host (4.3.11).
Is there anyway to do the transform without getting the later(/est) php version?
TIA,
J
Of course, my major problem is that I can't install extensions anyway since it's not my server.
I can't be the first person to require XSLT in PHP4!
all advice or suggestions will be muchly appreciated.
there are also XSL functions [php.net]. Not having control over the server is indeed an issue at times, but most decent hosts will accommodate by either allowing you to compile in your own server space and/or do it for you.
[uk2.php.net...]
// Transform $xml data using $xslFile
// e.g. xslTransform('<myxml>data</myxml>','my.xsl')
function xslTransform($xml, $xslFile)
{
$args = array('/_xml' => $xml);
$xslt_args = array();
$xh = xslt_create();
$r = xslt_process($xh, 'arg:/_xml', $xslFile, NULL, $args, $xslt_args);
xslt_free($xh);
return $r;
}
It now seems that I try and run the following code nothing is returned in Fx (very odd - it just keeps the previous page contents and doesn't complain), and IE shows 'the page cannot be displayed'.
// Allocate a new XSLT processor
$xh = xslt_create();// Process the document
if (!xslt_process($xh, 'pricegraphxmldata.xml', 'cptj.xsl', 'result.xml'))
echo("Sorry: " . xslt_error($xh) . " and the error code is " . xslt_errno($xh));
else echo("successful");//
xslt_free($xh);
-----
I'm fairly sure that this exact code has worked earlier today.
<edit by coopster>
Search for "devdump" in the User Contributed Notes on [php.net...]
</edit>
it serializes your xml into an array that you can easily transform.
[edited by: coopster at 1:57 pm (utc) on Oct. 5, 2005]
[edit reason] removed url per TOS [/edit]