I've got some code which draws data from an xml file but it seems to have randomly starting throwing;
Traceback (most recent call last):
File "C:\Users\mike\Documents\python\arl xml\turn 24 reader", line 52, in <module>
unitCount = getText(evoNode.getElementsByTagName("count")[0].childNodes)
IndexError: list index out of range
it was fine for the first couple of times I ran it then, I dunno if I changed it or not by accident, but now it's throwing the error.
This is an example of the section of the xml it's trying to use;
- <unit>
<count>1200</count>
<type>Zweihander Doppelsoldners</type>
<typeid>102</typeid>
</unit>
and here's the code that it's complains about;
for unitNode in node.getElementsByTagName('unit'):
unitName = getText(evoNode.getElementsByTagName("type")[0].childNodes)
unitId = getText(evoNode.getElementsByTagName("typeid")[0].childNodes)
unitCount = getText(evoNode.getElementsByTagName("count")[0].childNodes)
unitList.append("%s x %s" % (unitName, unitCount))
While I accept that it complains about the count line first because count is the highest of the three on the xml file in the units section I'm still not sure why it's complaining, given that it succesfully runs a very similar set of code from which that was cloned and editted.
Anyone know what I can do or can suggest ways to refine the question?