Skip to content
WJunction - Webmaster Forum

Using XML to extract

Status
Not open for further replies.
Hi there, i have a quick query.
Is there a way to process a online xml file instead of having the xml file on your server?

I have this so far:

<!DOCTYPE html>
<html>
<body>

<script>
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","sitemap.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

document.write();
var x=xmlDoc.getElementsByTagName("url");
for (i=0;i<x.length;i++)
{
document.write(x.getElementsByTagName("priority")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write("<br />");
}
document.write("</table>");
</script>

</body>
</html>

Obviously, this only returns the "priority" which in this case turns out like this:

1.000
0.5000
0.5000
0.5000
0.5000
0.5000
0.5000
0.5000
0.5000
0.5000
0.5000

and so on.

My question is, is there a way to change it so that i can run it to the xml online link which is:

http://www.google.co.uk/sitemap.xml
 

1 comment

hum.
what do you want to do?
execute your script and trying to parse google.co.uk/sitemap.xml ?

if yes, this won't work - unless you have the script on google.co.uk
This is a browser security issue (since javascript is working in the browser)
It's called "cross site scripting"

you can try doing it with sforce.connection.remoteFunction() from ajax-toolkit
or you have to rewrite this do php and do it serverside - this should work, too
 
Status
Not open for further replies.

About the author

B
Senior Member · Joined
1,286
Messages
211
Reactions
63
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom