Forum Moderators: coopster
I have one site that contains a PHP file that basically outputs an XML formatted list depending on the file structure in that directory.
The other site needs this XML formatted data to complete the PHP generated XML file that I am trying to put together. (Much like syndicating my content from one site to another)
I have tried using readfile, include and header(Location:) and none of them seem to be working. What I need is for the calling file to somehow include the output of the remote file. (The same stuff you see if you view the source) What happens is that I can 'readfile' my index page on that site, but not the one that puts out the XML data that I need. Could it be that the XML file doesn't actually create any visual content on the page? or doesn't have 'head' and 'body' tags?
It would be great if I could do all of this in PHP so that the final source would not include anything that would disrupt the final XML output.
Does anyone have any suggestions?
Is your XML file being generated by a php file and stored statically? e.g. xml.php outputs a file something.xml? If it isn't I'd probably write it so that is is output statically and then use the function file_get_contents() on the URL to the file.
If it's being generated dynamically each time, I think some of the functions will just read the php file without the parser running over it, which would be useless. I'm not sure how, if at all, you can read the dynamically generated contents of a php file unless you pass the output as a variable.
Warning: file_get_contents(http://www.domain.com/directory/file.php): failed to open stream: HTTP request failed! HTTP/1.1 404 in d:\other_domain\html\test\other_file.php on line 16
(If I call the file.php in my browser it works fine.)
Line 16 looks like this:
$xml_data = file_get_contents($xml_file);
if I "urlencode($xml_file)" I get an error that the file does not exist.
Could this be something in my php.ini file on the domain I'm trying to get the file contents from? Or could it be that the file I'm trying to read does not have <head> or <body> tags?
[php.net...]
HTH