如果您更喜欢纯 GAS 方法并使用 Logger,这里有一种方法可以查看在哪里......
function myFunction() {
var single_quote_returntxt = UrlFetchApp.fetch("http://www.google.com/ig/api?stock=0005").getContentText();
Logger.log(single_quote_returntxt)
var quoteinxmldoc = Xml.parse(single_quote_returntxt,true);
var topelements = quoteinxmldoc.getElement().getElement().getElements();
for(var e in topelements){
var element = topelements[e]
var att = element.getAttributes();
for(var a in att){Logger.log('Element '+e+' ='+element.getName().getLocalName()+' attribute :'+ att[a].getName().getLocalName()+' : '+att[a].getValue())}
var wantedelement = element.getElements();
for(var w in wantedelement){Logger.log('wantedelement '+w+' :'+wantedelement[w].getText())}
}
}
记录器.log =
Element 0 =symbol attribute :data : 0005
Element 1 =pretty_symbol attribute :data : 0005
Element 2 =symbol_lookup_url attribute :data : /finance?client=ig&q=0005
Element 3 =company attribute :data : HSBC Holdings plc (Hong Kong)
Element 4 =exchange attribute :data : HKG
Element 5 =exchange_timezone attribute :data :
Element 6 =exchange_utc_offset attribute :data :
Element 7 =exchange_closing attribute :data :
Element 8 =divisor attribute :data : 2
Element 9 =currency attribute :data : HKD
Element 10 =last attribute :data : 84.55
Element 11 =high attribute :data : 84.95
Element 12 =low attribute :data : 84.10
Element 13 =volume attribute :data : 17368416
Element 14 =avg_volume attribute :data : 12414
Element 15 =market_cap attribute :data : 1562574.91
Element 16 =open attribute :data : 84.40
Element 17 =y_close attribute :data : 84.15
Element 18 =change attribute :data : +0.40
Element 19 =perc_change attribute :data : 0.48
Element 20 =delay attribute :data : 15
Element 21 =trade_timestamp attribute :data : 5 hours ago
Element 22 =trade_date_utc attribute :data : 20130319
Element 23 =trade_time_utc attribute :data : 075959
Element 24 =current_date_utc attribute :data : 20130319
Element 25 =current_time_utc attribute :data : 132906
Element 26 =symbol_url attribute :data : /finance?client=ig&q=0005
Element 27 =chart_url attribute :data : /finance/chart?q=HKG:0005&tlf=12
Element 28 =disclaimer_url attribute :data : /help/stock_disclaimer.html
Element 29 =ecn_url attribute :data :
Element 30 =isld_last attribute :data :
Element 31 =isld_trade_date_utc attribute :data :
Element 32 =isld_trade_time_utc attribute :data :
Element 33 =brut_last attribute :data :
Element 34 =brut_trade_date_utc attribute :data :
Element 35 =brut_trade_time_utc attribute :data :
Element 36 =daylight_savings attribute :data : true
但是 Mogsdad 方法更清洁、更快……毫无疑问 ;-)