Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3518] Android: Attempt to retrieve root element from XML returns null object

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2017-05-01T20:40:47.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterZhigang Xu
AssigneeIngo Muschenetz
Created2011-04-15T03:46:12.000+0000
Updated2017-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

Comments

  1. Lee Morris 2017-05-01

    Resolving ticket as invalid as this version of Kitchen Sink is no longer supported.

JSON Source