Javascript reads XML totally wrong

Hy guys,I'm developing HTML5/Canvas game engine and I'm stuck. The engine draws the map via tilesets, and reads the map data from a XML document, wich looks like this:\[code\]<map> <layer id="-1"> <row>0,0,0</row> <row>1,1,1</row> <row>0,0,0</row> </layer> <layer id="1"> <row>0,0,0</row> <row>1,1,1</row> <row>0,0,0</row> </layer></map>\[/code\]And the Javascript wich loads the data in a 2-dimensional array:\[code\]var layers = xml.getElementsByTagName("layer");for(var i in layers){ var rows = layers.childNodes; for(var j in rows) { array[j] = rows[j].nodeValue; } }\[/code\]The problem: the returned data is just a mishmash of "null", "", and "undefined". Also, the array seems to be smaller then necessary, because before I go through all the values I check the number of nodes (with the length attribute), and it's always more then the actual number of nodes.
 
Back
Top