ManfredJ.: Hosting für serverseitige Transformation

Beitrag lesen

Eine Frage hätte ich doch noch.
Wie lässt sich das XML-Dokument an dieser Stelle filtern?

$xmldocument=file_get_contents("test.xml");

test.php:

<?php

$xmldocument=file_get_contents("test.xml");
  $xsldocument=file_get_contents("test.xsl");

// Transformation:
  if($xmldocument && $xsldocument)
  {
    $xmlobj=new DomDocument();
    $xmlobj->loadxml($xmldocument);
    $xslobj=new DomDocument();
    $xslobj->loadxml($xsldocument);

$xsltref=new XSLTProcessor;
    $xsltref->importStylesheet($xslobj);
    $xsl_output=$xsltref->transformToXML($xmlobj);

echo $xsl_output;
  }

?>


>   
>   
> Ergebnis (HTML):  
>   
> ~~~html

<?xml version="1.0" encoding="UTF-8"?>  

> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
> <html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de">  
>   <head>  
>     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  
>     <title>Test</title>  
>   </head>  
>   <body>  
>     <h1>Hallo Welt!</h1>  
>     <p>123</p>  
>   </body>  
> </html>

Grüße,
Thomas