My index.htm acts like a search engine. The user can click hard links to search results or use the search box. My partner search engine wants a url containing the user's ip and query, and I'm returned an xml feed with the results.
I pass the query to search.php, use server functions for the IP stuff, urlencode and come up with this string:
$request = 'http://partners.searchengine.com/MYID?' . $querystring;
Then I try and submit the query and get the xml back:
$xmlfeed=file($request);
This returns an array. Echo prints "array" to the screen, whereas echoing $request and copying and pasting the resulting URL into the browser displays well-formed XML data. I've also tried a companion function:
$xmlfeed=file_get_contents($request);
Echoing this gives strings of poorly formed text results (and only if I do ("$request"), in other words put quotes around $request in the get).
I've made su.xsl and have it on my root dir. I want to use an XSLT processor to combine my xml with xsl and display the results nicely in the browser ala google. I tried the code:
//Create an XSLT processor
$xsltproc = xslt_create();
// Perform the transformation
$html = xslt_process($xsltproc, $xmlfeed, 'su.xsl');
// Detect errors
if (!$html) die('XSLT processing error: '.xslt_error($xsltproc));
// Destroy the XSLT processor
xslt_free($xsltproc);
// Output the resulting HTML
echo $html;
I get the error messages. I tried a variation with:
$xsl= 'su.xsl';
$arguments = array(
'/xml' => $xml,
'/xsl' => $xsl);
$result = xslt_process($xh, 'arg:/xml', 'arg:/xsl', NULL, $arguments);
This gets me farther so long as I use:
$xmlfeed=file_get_contents("$request"); //notice the quotes around $request
I've wondered if using the xslt_process() function requires something different than the array or string $xmlfeed. Do I need to somehow save $xmlfeed as an .xml file for this all to work? I tried a function that I found array_to_xml($xmlfeed); Thus far it has given me parse error messages, saying an unexpected $ at the end of the file.
So, is it obvious? Am I making a rookie mistake in trying to use variables where I shouldn't?
Thank you.