我正在使用 Appcelerator Titanium,下面的代码在 iPhone 上运行良好,但在 Android 上运行良好,我无法找出原因。任何人都可以帮忙吗?
它失败并出现以下错误:
TypeError:无法从 null 读取属性“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