View Full Version : PhoneGap + Sencha Touch loading local XML files

28 Jul 2011, 12:49 PM
Does anyone know the proper way to load a local XML file with PhoneGap and Sencha Touch?

I've scoured the internet looking for a good solution to this problem, but so far I've not found any good answers...

The funny thing is -- everything works fine when I deploy to my Droid Incredible, and in my Android 2.2 and 3.0 emulators. It does not work in my Android 2.1 emulator. No data is loaded. The rest of the app works fine in all.

InterviewApp.stores.flashCardStore = new Ext.data.Store({
model: 'FlashCard',

proxy: {
type: 'ajax',
url : 'Questions.xml',
reader: {
type: 'xml',
root: 'InterviewQuestionList',
record: 'InterviewQuestion'

InterviewApp.stores.flashCardStore.on('load', function() {
alert('will never get here');


Again, it works fine on the Droid Incredible and the Android 2.2 and 3.0 emulators. Does not work on Android 2.1 emulator. Everything else works. The app loads fine. It's just my data that never shows up.

29 Jul 2011, 5:13 AM
This kinda sucks, but I've gotten this to work now by using a combination of Sencha Touch and jQuery. I didn't want to have to add jQuery into the mix... but this works:

type: "GET",
url: "Questions.xml",
dataType: "xml",
async: false,
success: function(xml) {
$(xml).find('FlashCard').each(function() {
"Question": $(this).find('Question').text(),
"Answer": $(this).find('Answer').text(),
"Category": $(this).find('Category').text()

InterviewApp.stores.flashCardStore = new Ext.data.Store({
model: 'FlashCard',
data: flashCards

Please, I'm very much open to suggestions for a better way to do this. Preferably using all sencha code.

1 Aug 2011, 11:06 PM

I did have a similar problem loading local xml files on Android devices using Sencha Touch in combination with PhoneGap.

My app ran pretty well on both Android and iOs as pure web app. It also worked fine as PhoneGap version on iOS.

However the PhoneGap version for Android always failed to load the xml data, giving me the following error message :

Object #<an Object> has no method 'querySelectorAll' at file:///android_asset/www/js/sencha-touch-1.1.0/sencha-touch-debug.js:13201

This problem occured no matter what Android device or PhoneGap version I was working with.

Luckily, I could finally fix it by replacing the relative path with absolute URLs.



13 Dec 2011, 10:57 PM
A call using AJAX, JSON or YQL causes an issue on Android 2.1

I have tried my code and kitchen sink using PhoneGap on various android versions and only 2.1 has an issue:(. I am not the most experienced, little help too please?

21 Dec 2011, 4:35 AM
I fixed my issue by implementing what is on this post:

Does this work for you?

If you are looking to implement it in the compressed version it becomes:

if ((a>= 200 && a< 300) || a== 304 ||
(http://www.sencha.com/forum/showthread.php?146008-HTTP-status-of-0-prevents-json-from-loading-in-phonegap&langid=4)(a== 0 && d.xhr.responseText.length > 0) ) {