How do I serve an XML file as a web service in PHP?
I would like to have a web service in PHP simply send an existing XML file - this is to get around the cross-site XMLHttpRequest limitation. I need to read it in JavaScript on the client end.
Can this be done?
I am a PHP n00b, so any code example some kind soul can provide would be greatly appreciated.
:-)
Re: How do I serve an XML file as a web service in PHP?
All you need is to set your header for XML content and then output pure XML.
PHP Code:
<?php
header ("Content-Type: text/xml");
echo $xmlContent;
?>
Re: How do I serve an XML file as a web service in PHP?
That's cool, but I think you're still limited by JavaScript's inability to read a file located on another server. I was really looking to make it into a Web Service I can call.
Thanks, though, I did learn something.
Re: How do I serve an XML file as a web service in PHP?
You misunderstand JavaScript's cross-domain policy. JavaScript can read files on other domains...it cannot interact with DOM elements on other domains.