xsltprocessor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux