I discovered an issue with android emulator versions 2.1 and less; specifically, I tested it on the android emulator, versions 1.5, 1.6, and 2.1. I thought that early android versions did not have full or any support for jQuery or ajax, which sounds idiotic to say, but I didn’t realize it was picky about the XML file structure. Each of my XML files start with the following XML declaration:
<?xml version="1.0" encoding="Shift-JIS"?>
Now, Android 2.3.3 and greater and iOS have no issues. Perhaps Android 2.2 may have issues, but I don’t see it available in the SDK Manager for Android.
If I take this XML declaration out of an XML file, these early Android version loads the XML file.
Does not work:
<?xml version="1.0" encoding="Shift-JIS"?>
<test>Hello World</test>
Works:
<test>Hello World</test>
I tried it using both jQuery.ajax() and XMLHttpRequest and the results above hold.
$.ajax({type: "GET", "test.xml": url, cache: false, async: false});
The question is why is it that these early versions of android cannot parse the XML structure with the XML declaration? Perhaps, an android 1.5 device can parse it, but I cannot verify that. I can only verify these versions of android emulator have serious issues with XML declarations in an XML file.
I’m hoping there’s a workaround and would appreciate any help.
Thank you.
The XML declaration is not actually needed for valid XML. But it does allow you to define the encoding used in the file. I don’t have access the sources currently but I bet the if you were to change the encoding defined in the declaration to UTF-8 or ISO-8859-1 that it will parse the XML just fine. I have been able to parse XML with Android using the UTF-8 encoding.