[TIMOB-3518] Android: Attempt to retrieve root element from XML returns null object
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2017-05-01T20:40:47.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | Zhigang Xu |
Assignee | Ingo Muschenetz |
Created | 2011-04-15T03:46:12.000+0000 |
Updated | 2017-05-02T21:34:24.000+0000 |
Description
The following code snippet is a much simplified version of xml_rss.js from KitchenSink:
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function(){
try {
var doc = this.responseXML.documentElement;
// var anXml = Ti.XML.parseString(this.responseText);
// var doc = anXml.documentElement;
var rootElem = doc.getElementsByTagName("rss");
Ti.API.info("rootElem array:" + rootElem.length);
Ti.API.info("rootElem Text:" + rootElem.item(0).getText());
}
catch (e) {
alert(e);
}
}
// open the client xhr.open('GET','http://v2.0.news.tmg.s3.amazonaws.com/feeds/news.xml')">http://v2.0.news.tmg.s3.amazonaws.com/feeds/news.xml');
// send the data xhr.send();
The service URL is the same one used in xml_rss.js. The root
element tag of the return XML message is "rss". In my code, the
call
var rootElem = doc.getElementsByTagName("rss");
results in an empty array rootElem for both Android Emulator and
actual Android device. The same code runs fine on IPhone, which
returns an array with a single element.
I'm using Titanium Mobile SDK 1.6.0.
Regards,
Zhigang Xu
Resolving ticket as invalid as this version of Kitchen Sink is no longer supported.