0

I'm developing a HTML5 application for Blackberry OS 5+.

I have to get a remote xml file from http://domain.com/xxx/mTop and parse it to show it as a list.

I'm trying to do it with jQuery and AJAX but I get an issue with Same Origin Policy.

My question is, how can I get a remote XML file and show it as a list?

It is not really a file, it is a web service that returns a XML. If that web service returns a JSON, could I parse it?

By the way, I've asked this question that is related to this one

Community
  • 1
  • 1
VansFannel
  • 45,055
  • 107
  • 359
  • 626
  • The answer is that you cannot. It is a violation of the same origin policy. Your site cannot access a remote file unless your site is on the same domain as that remote file. If the remote site has JSONP support or the remote server implements CORS you are ok. If the remote site does not do this and you do not control the remote site your only option is to have your server download that file and then serve it to your HTM5 app. – Adam Jul 25 '12 at 18:10
  • It is not really a file, it is a web service that returns a XML. If that web service returns a JSON, could I parse it? – VansFannel Jul 25 '12 at 19:16
  • The problem as I understand it is not a parsing issue. You cannot get XML at all from a remote server including a web service if it is on a different domain. See http://stackoverflow.com/questions/9047155/cross-domain-ajax-request-returning-xml-origin-http-is-not-allowed-by-acc – Adam Jul 25 '12 at 19:38

2 Answers2

0

You can build an intermediary on your own domain in a server language (PHP for instance) that interacts with the other domain (file_get_contents, curl, etc), then echos the response...then your app just interacts with that proxy instead of the separate domain.

Robot Woods
  • 5,677
  • 2
  • 21
  • 30
  • It is not really a file, it is a web service that returns a XML. If that web service returns a JSON, could I parse it? – VansFannel Jul 25 '12 at 19:17
  • You should be able to interact with a service in the same way (particularly if it accepts parameters in the URL...if they have to be POST'd then you'll need to use cURL) And why wouldn't you be able to parse it? You're just passing the response from the service, through your proxy, to your client. – Robot Woods Jul 25 '12 at 19:20
0

XML is not allowed for cross-domain requests by default.

ARIF MAHMUD RANA
  • 5,026
  • 3
  • 31
  • 58
  • It is not really a file, it is a web service that returns a XML. If that web service returns a JSON, could I parse it? – VansFannel Jul 25 '12 at 19:16
  • By default you can't. But may be I see somewhere with some modifications it may be possible. I suggest you build a wrapper using your server side scripting language where you call to your script and that will call to your web service and return the response. – ARIF MAHMUD RANA Jul 26 '12 at 04:13
  • I don't have access to the server hosting web service. I've asked about JSON because I don't know it I will have the same problem with it. – VansFannel Jul 26 '12 at 04:32
  • You should create a wrapper script in your hosting. – ARIF MAHMUD RANA Jul 26 '12 at 10:24