我正在使用Appcelerator Titanium,下面的代码在iPhone上正常工作,但在Android上没有,我无法找出原因。谁能帮忙?为什么此Appcelerator代码在iPhone上工作,但不在Android上?
它失败,出现以下错误:
类型错误:无法从空读取属性“DocumentElement”
BEGIN CODE
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function() {
var xmlDoc = Ti.XML.parseString(this.responseText).documentElement;
var xlinestatus = xmlDoc.getElementsByTagName('LineStatus');
for (i = 0; i < xlinestatus.length; i++) {
var theItem = xlinestatus.item(i);
var newname = theItem.getElementsByTagName("Line").item(0).getAttribute("Name");
var desc = theItem.getElementsByTagName("Status").item(0).getAttribute("Description");
var active = theItem.getElementsByTagName("Status").item(0).getAttribute("IsActive");
Ti.API.info(" Line: " + newname + " Status: " + desc + ", Active: " + active);
}
};
// open the client
xhr.open('GET', 'http://cloud.tfl.gov.uk/TrackerNet/LineStatus');
// send the data
xhr.send({});
END CODE
你将不得不提供更多信息什么是logcat输出? 是否有一个例外是什么this.responseText的价值? – sherif 2011-03-20 21:59:36
我有类似的问题,请检查问题:http://stackoverflow.com/questions/8163385/xml-parsing-failure-on-android-but-works-on-iphone – 2011-11-17 07:25:18
http://developer.appcelerator.com/question/128341/xml-parsing-failure-on-android-but-works-on-iphone – 2011-11-17 07:26:08