I have a script which generates an XML file when the user accesses the link like so:
domain.com/dirList.php
I would like to print the contents of the XML to the user at the end of the POST or GET request (have not implemented this yet). At the moment I am just viewing the link through a web browser.
This is the code I am using to print the file contents.
# Open XML file and print contents
$filename = "test.xml";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
fclose ($handle);
print $contents;
The problem is that it doesn't seem to be working. I think I might be either missing a header like this: ("Content-Type: text/xml");
or maybe my code is wrong.
What do I need to do to get the XML file to print to the browser?