如何从Google解析JavaScript中的XML [英] How to parse XML in JavaScript from Google

查看:183
本文介绍了如何从Google解析JavaScript中的XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想解析这个XML文档 http://www.google .de / ig / api?weather = Braunschweig,%20Deutschland 我希望能够读出条件,temp_c和湿度。所有这些我想在JavaScript内部进行,而不使用任何服务器端脚本,如PHP,我希望它能够在现代浏览器以及IE7上工作,如果没有很多问题,IE6
编辑:
没有解决方案一个框架是理想的

I want to parse this XML Document http://www.google.de/ig/api?weather=Braunschweig,%20Deutschland I want to be able to read out condition, temp_c and humidity. All this I want to do inside of JavaScript without using any server sided scripts such as PHP and I want it to work on modern browsers as well as IE7 and if without many problems IE6 A solution without a framework would be ideal

推荐答案

除非您正在google.de上托管的页面上工作 - 否则你不能。

Unless you are working on a page hosted on google.de — you can't.

同源政策阻止JS运行在您网站的网页中访问远程站点上的文档。

The same origin policy prevents JS running in a webpage on your site from accessing a document on a remote site.

您必须涉及服务器端进程才能将XML转换为您的格式可以远程处理(例如JSON-P, Yahoo! Pipes 将为您做)或转发数据通过您自己的服务器,服务器端进程可以在与页面相同的原点访问。

You have to involve a server side process in order to either convert the XML into a format that you can handle remotely (such as JSON-P, which Yahoo! Pipes will do for you) or relay the data through your own server with a server side process accessible in the same origin as the page.

这篇关于如何从Google解析JavaScript中的XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆