Hi,
you might start by using some braces to explicitly delineate the
if and foreach block? ...personally I'm not sure exactly what your
code
should be doing.
Putting the brackets in doesn't make any difference. That part of the
code appears to work perfectly - what it does is scan through the xml
document looking for a 'section' tag with the attribute id equal to
the get variable 's' and with a 'subsection' tag with attribute id
equal to the get variable 'ss'. Doing echo $content->asXML(); right
after the if and foreach shows that the $content variable does indeed
hold the right content.
The problem is then applying the xsl transform to what is in that
variable. It appears to transform everything in $xml, rather than
just what is in $content.
$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
Allan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php