I wonder, is any interest in this thread still?
I know it's a few months old but it pretty much parallels what I've been working on exactly. (right down to the code from php.net)
Mine wasn't working until I saw your post with this:
// Get XML from web
$file = fopen($xml_file,"r");
while(!feof($file))
$xml .= fgets($file, 1024);
fclose($file);
Thanks I was trying to use fgets() and couldn't get it to work right.
I'm still hung up on a problem
My php/xml source file is actually a reply from a remote server that is POSTed an xml message from my server using cURL. Part of the message I send is a list of products looped out of a MySQL database. My query depends on a session array and I can't seem to get it to persist.
My code is pretty much identical to yours and I've changed my variable names to reflect what you've come up with. It is as follows:
<?php
//I NEED TO MAINTAIN THE SESSION HERE
session_start();
// Source files
$xml_file = "http://localhost/dcduby/boutique/shipping_data.php";
$xsl_file = "test.xsl";
// Get XML from web
$file = fopen($xml_file,"r");
while(!feof($file))
$xml .= fgets($file, 1024);
fclose($file);
// Gonna contain PHP-XML output
$args = array('/_xml' => $xml,);
// Allocate a new XSLT processor & process the document
$xh = xslt_create();
$result = xslt_process($xh, 'arg:/_xml', $xsl_file, NULL, $args);
// Detect errors
if (!$result) die('XSLT processing error: '.xslt_error($xh));
// Output the resulting HTML
echo $result;
// Destroy the XSLT processor
xslt_free($xh);
?>
It looks to me from the results I am receiving that the query was never initated and that the message I sent with cURL was lacking the list of products. my xml is transformation is fine.
Any idea how to prevent the session from dissapearing?
Thanks
Andrew