[PHP - XSLT - Sablot] Remote XML gebruiken

Pagina: 1
Acties:

  • oZy
  • Registratie: Juli 2001
  • Laatst online: 22:30
Zoals je hier kunt lezen werken m'n xml/xsl prima, maar zodra ik de xml vanaf een remote site wil openen gaat PHP jammeren.. Ik heb deze code van Freak007 geprobeert, maar ik denk dat dit door nieuwere versies van PHP/Sablot niet meer werkt (bij mij althans).
PHP:
1
2
3
4
5
6
7
8
9
10
<? 
$xsl = implode('', file('traffic.xsl')); 
$xml = implode('', file('http://www.blaat.nl/traffic.xml')); 

$xh = xslt_create()

$result = xslt_process($xh, $xsl, $xml); 
 
echo $result; 
?>


Error:
code:
1
Parse error: parse error, unexpected T_VARIABLE in /blaat.php on line 7

  • brammetje
  • Registratie: Oktober 2000
  • Laatst online: 12-01-2025
zoeken had ws ook wel geholpen, maar hier, lekker c/p omdat ik in zo'n goede bui ben...

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Transform a xml string with a xsl string
*
* This function transforms the given xml string with the given xsl string.
* Therefor it creates a xslt processor.
* NOTE: This function is found succesfull with PHP 4.1.0. Using on other version
* is NOT recommended.
* NOTE II: Do look carfully at the parameters. The xml is supposed to be given
* as a string containg the xml data, but the xsl should be given as a path to
* the xsl file!
*
* @param    string      $xml    The xml data to transform
* @param    string      $xsl    The xsl file used for transforming $xml
* @return   string      The transformed xml
* @access   public
* @author   Rense Klinkenberg <r.klinkenberg@student.utwente.nl>
*/
function XSLTransform($xml, $xsl) {
    // Process the document, returning the result into the $result variable
    // $xml and $xsl contain the XML and XSL data
    $arguments = array(
         '/_xml' => $xml,
         '/_xsl' => implode('', file($xsl))
    );
    // Allocate a new XSLT processor
    $xh = xslt_create();    
    // Process the document
    $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);    
    // Free the XSLT processor
    xslt_free($xh);    
    return $result;
}