Problem with parsing XML
Hello,
i try to parse a XML-String but, that I receive via a HTTP-Client. No problems so far.
var ManifestXML = this.responseText;
var xml_as_dom = Titanium.XML.parseString(ManifestXML);
Then I try to get a node - works too
var my_items = xml_as_dom.getElementsByTagName("item");
with the length-attribute I can see, that 7 nodes are being returned, which is correct. But now I can not treat the returned variable as array.
The following line does not work
alert(my_items[0]); //returns 'undefined'
Has anybody a suggestion?
I use the mobile SDK 1.0.0 for iPhone
Thanks in advance,
Carsten
2 Answers
-
OK, found an answer…
The returned variable (my_items) is not an array but an object (type: TiDomNodeList)
You can access it by using
my_items.item(0); // 1,2,3,4,5,.....
-
On shortcut, just use the property this.responseXML to get the DOMDocument directly.