我想知道是否有办法在钛中获取html文件的内容,就像使用xml文件一样。例如,对于xml文件,我可以在抓取内容时创建一个httpclient,如下所示:
var metaDataURL="some_xmlfile";
var xhr=Titanium.Network.createHTTPClient();
xhr.open('GET',metaDataURL);
xhr.send();
xhr.onload=function(){
alert("loaded");
}
xhr.onerror = function(e) {
alert(e.error);
};
我需要信息的网址是:
http://50.7.242.154:8070/7.html
所有内容都有一些数字以及歌曲和艺术家的名字。我有什么方法可以做到这一点吗?
答案 0 :(得分:0)
您以相同的方式使用它,您只需从服务器获取文件即可。基本上是下载。
var xhr=Titanium.Network.createHTTPClient({
onload : function(e) {
var htmlresponse = this.responseText;
// Do what you want with the HTML now
}
});
xhr.open('GET','http://50.7.242.154:8070/7.html');
xhr.send();