Phonegap Xml to Json Example
seen from United States
seen from China
seen from Mexico
seen from China

seen from Malaysia
seen from South Korea
seen from South Korea

seen from Malaysia

seen from T1
seen from T1
seen from Brazil

seen from T1

seen from T1
seen from Australia
seen from Türkiye
seen from Singapore

seen from United States

seen from United States
seen from China
seen from United States
Phonegap Xml to Json Example
Titanium에서 RSS를 Backbone Collection으로 사용하기
Backbone Model을 이용해서 Titanium이나 Web개발시 데이터를 다루면 참 편하다. rss를 다룰 일이 있어서 Titanium에서 Alloy의 Model을 사용하지 않고 Backbone의 모델을 확장해서 만든 모델을 공유한다. rss피드이기 때문에 fetch만 하면 되므로 따로 Sync를 만들지 않고 fetch함수만 만들었다. xml자체를 json으로 parsing 할때는 David Bankier의 XMLTools for Titanium을 사용하였다.
var _ = require("alloy/underscore")._, Backbone = require("alloy/backbone"); var Collection = Backbone.Collection.extend({ initialize : function(models, options){ options = options || {}; this.url = options.url }, fetch : function(options){ options = options || {}; var collection = this; // Create an HTTPClient. var anXhr = Ti.Network.createHTTPClient(); anXhr.setTimeout(10000); // Define the callback. anXhr.onload = function() { var XMLTools = require("XMLTools"); var parser = new XMLTools(this.responseText); var jsonObj = parser.toObject(); // jsonObj.channel.item는 사용한 rss의 item 배열명에 맞게 수정한다. collection[options.add ? 'add' : 'reset'](jsonObj.channel.item, options); if (options.success) options.success(collection, resp); }; anXhr.onerror = function(e){ collection.trigger('error', collection, e, options); }; // Send the request data. anXhr.open('GET',this.url); anXhr.send(); } }); exports.Collection = Collection;