Problems with dom

Hi

I have a problem with using DOM that is has been annoying me for days. I’m trying to use an xslt process to match up an xml and an xsl file with dom documents. The easiest way I’ve found, which is basically used in most of the examples I’ve found, is the following…

<?php

$xml = new DOMDocument();
$xml->load('xmlfile.xml');

$xsl = new DOMDocument();
$xsl->load('xslfile.xsl');

$xslt = new XSLTProcessor();
$xslt->importStylesheet($xsl);
echo $xslt->transformToXML($xml);

?>

I can’t use this for the simple reason the the load() method in the DOMDocument class does not exist for me, nor can I find any information as to why it doesn’t and I’ve been trying to find some kind of explanation for days now.

(No version information available, might be only in CVS)
From: http://www.php.net/manual/en/function.d ... t-load.php

I’m thinking the above is true and you don’t have the CVS version of PHP. It doesn’t look like there are any alternative methods implemented in the binaries either.

So how do you create a DOMDocument from a file or a string then? The XSLTProcessor requires DOMDocument, with both the old xslt_functions and dom_xml functions not being bundled with PHP anymore there doesn’t seem to be anyway to load an xml or an xsl file to create a DOMDocument.

I’m afraid there aren’t any alternatives to what you’re trying to do (at least, not without using some third-party’s custom code). Your best bet would be to uninstall your current PHP installation, and install from a CVS version. Keep in mind though, that this doesn’t guarantee the required functionality will be available to you! Read up on the release notes to see if it does. Best would be to prepare a separate (virtual) machine and use that. If that doesn’t give you a solution, I’m afraid you’re going to have to script your own functionality for transforming XML :(

Sponsor our Newsletter | Privacy Policy | Terms of Service