0

Hi
Is it possible to load an XML file from a domain that differs from scripts domain with pure javascript and without using a php/asp/jsp/... script as proxy?
Something like xmlHttpRequest but with ability to manage cross domain requests.

Thanks

2 Answers 2

2

You can use something called JSONP. I know the name sucks, because it's not really related to JSON. But this requires you have control over the other domain. You need to wrap your XML inside a function call, or assign it to a javascript variable:

func('<xml></xml>');

or

var myxml = '<xml></xml>';

So if your other domain returns one of these two formats, you can use the <script src="http://otherdomain/yourjsonp"></script> syntax in your html to load that data in JavaScript. It's a little hacky but a lot of people use it.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi, thanks. but it doesn't help me. actually I need to load other sites RSS and traverse it with pure JS. So I just can read files that are provided by others and that file is XML.
Sorry then it's not possible.
0

It is possible with yql! (Yahoo did it for you)

Go to this site and simple at the "select from url='xxx' " replace the xxx with your xml url. Use the url created at the text box below and do a simple xmlrequest. You won't have any cross-domain prolems

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.