Need help on Javascript and xml, please help

After reading wonderful article by Premshree Pillai

haap://articles.sitepoint.com/article/server-side-xml-javascript
(replace haap with http)

I came to know how to handle xml using javascript if the xml is on your server.

But in the website I’m trying to build, I’m using a service to retrieve xml for each user that views my webpage. Actually I’m trying to access his IP address and then going to find his country.

browse following link
haap://ipinfodb.com/ip_query2_country.php?ip=74.125.45.100
(replace haap with http)

to this link if you give IP address as parameter, it gives a xml file which contains the country of the user.

Can someone tell me how can I create an object of XML using this file/url in JavaScript?

The reason you can’t is due to javascripts same domain policy. You can search for more info.

What you can do:
Create a serverside script, for example with php or another language. That script can request the remote url. It basically acts as a proxy, so javascript only needs to request a url on your own server, and then php fetches the content from the other domain.

You might wanna just skip that other website altogether. You can get free ip to country databases from maxmind and just do it all yourself on your own server.

It is easier to do it on the server side by querying a GeoLocation database like IP2Location or a free web service like [URL=“http://www.fraudlabs.com”]FraudLabs. You can always try to do it on the client side using AJAX but if the user has turned off JavaScript or the browser for some reason doesn’t support either JavaScript or AJAX then you will have a big headache.