xsltprocessor

From: Date: Sun, 31 Jul 2005 14:22:28 +0000
Subject: xsltprocessor
Groups: php.general 
Request: Send a blank email to php-general+get-219709@lists.php.net to get a copy of this message
Hello all, I'm having a real problem with applying an xslt transform to a selected part of an xml document. I load the xml document using simplexml_load_file, and the same with the xsl file. Using the xpath function for simplexml I select a part of the xml document and store it in a different variable. I then apply the xml transform to that variable, however the transform actually applies to the whole xml document, rather than just the selected part in the new variable. I can't figure out why it does this. Does anyone know? The code I'm used is below. $xml = simplexml_load_file ( 'simple_test.xml' );
    if ( isset ( $_GET['s'] ) && isset ( $_GET['ss'] ) )
        foreach ( $xml->xpath( "//section[@id='".$_GET['s']."']/subsection[@id='".$_GET['ss']."']" ) as $subsection)
            $content = $subsection;
    $xsl = simplexml_load_file( 'simple_test.xsl' );
    $proc = new XsltProcessor();
    $proc->importStylesheet($xsl);
    echo $proc->transformToXML($content);
Thanks for any help Allan

« previous php.general (#219709) next »