Appcelerator Q&A Link: XML Parsing failure on Android but works on iPhone
I am preparing a general application which works both for iPhone and Android phones with same code for which Titanium is majorly used for. With the same code I found different results for XML document parsing and my android app does not load it properly. It causes NULLPointer Exception. But the same code works perfectly on iPhone.
Can you check this?
xyz(languageCode, currentVersion, xmldoc) {
try {
Ti.API.info('Start parsing the library');
var archiveData = xmldoc.getElementsByTagName('archive');
Ti.API.info('Archive: ' + archiveData);
Ti.API.info('Item: ' + archiveData.item);
Ti.API.info('Lendth: ' + archiveData.length);
var newVersion = archiveData.item(0).getAttribute('version');
}catch(e){
Ti.API.info('Library Went In Catch: ' + e);
}
Function call: It's from onload() method of Ti.Network.HttpClient
xyz(languageCode, version,this.responseXML.documentElement);
Output of iPhone:
Archive: [object TiDOMNodeList]
[INFO] Item: [object TiDOMNodeList]
[INFO] Lendth: 1
Output of Android:
[INFO] [3,7225] Archive: [Ti.NodeList]
[INFO] [1,7226] Item: [KrollMethod item]
[INFO] [2,7228] Lendth: 0 [INFO]
[235,7466] Library Went In Catch: JavaException: java.lang.NullPointerException: null