{ "id": "63806", "key": "TIMOB-3174", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "12087", "description": "", "name": "Sprint 2011-47", "archived": true, "released": true, "releaseDate": "2011-11-28" } ], "resolution": { "id": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2011-11-29T15:45:58.000+0000", "created": "2011-04-15T03:38:49.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [], "versions": [ { "id": "11244", "name": "Release 1.7.0", "archived": true, "released": true, "releaseDate": "2011-06-13" } ], "issuelinks": [], "assignee": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2011-11-29T15:45:58.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}
We can't iterate over attributes in a node. We can only access\r\nthem by their name. We do expose the \"attributes\" property, which\r\ntoStrings as a \"[object TiDOMNamedNodeMap]\". The length property of\r\nattributes correctly returns the number of attributes an element\r\nhas, but there is no way to access an individual attribute by index\r\n(for example, node.attributes[0] is undefined).
\r\nFix the attributes property to let you access each attribute by\r\nindex, or expose a function to let you do this. The former approach\r\nwould be more inline with major browsers.
\r\nThe following sample code will write 'FAIL: some message' in a\r\nlabel if it isn't able to grab an attribute out of a simple XML\r\nstring. Otherwise, it will write out the attribute name and value\r\nin a happy green color.
\r\n\r\nvar win = Ti.UI.createWindow({ backgroundColor: '#fff' });\r\nvar label = Ti.UI.createLabel();\r\nwin.add(label);\r\n\r\nlabel.color = '#f00';\r\nlabel.text += 'FAIL: If you have time to read this, then we never finished reading the attributes.';\r\n\r\nvar dDocument = Titanium.XML.parseString('<?xml version=\"1.0\" encoding=\"utf-8\"?>\\r\\n<root foo=\"bar\" />');\r\nvar node = dDocument.documentElement;\r\nlabel.text = 'Found ' + node.attributes.length + ' attributes, ';\r\nfor (var i = 0; i < node.attributes.length; i++) {\r\n var attribute = node.attributes[i];\r\n if (attribute) {\r\n label.color = '#0f0';\r\n label.text += attribute.name + \" = \" + attribute.value;\r\n }\r\n else {\r\n label.color = '#f00';\r\n label.text += 'FAIL: attribute undefined.';\r\n }\r\n}\r\n\r\nwin.open();
\r\n
\r\nPulled from GitHub master last night: Titanium SDK version:\r\n1.7.0 (02/17/11 20:28 316c2c7)
\r\nBROKEN on iPhone Simulator 4.2
And what about .childNodes ?