-
June 9th, 2011, 08:10 AM
#1
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.
:-)
-
June 9th, 2011, 11:14 AM
#2
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; ?>
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
June 9th, 2011, 11:24 AM
#3
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.
-
June 9th, 2011, 11:46 AM
#4
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.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|