parsing - Parse xml data efficiently python using iterfind -


i parsing lots of repeating data large xml file(10mb), , on 100,000 of these files. want make sure i'm parsing efficiently. first make list of element paths want find. might 100-200 different elements, want find them , store them in dictionary key'd element name.

i've been using iterfind('/elementpath/'), returns generator have iterate through again text in each of elements. 2nd loop i'm trying eliminate

here code want best can optimize it. takes around 2 sec per file parse data. if can remove nested loop having improves 1.2 ms or so.

def parse_xml(testfile):     resultdict={}     search in searchlist:         resultdict[search]=[]         item in testfile.iterfind(search):             resultdict[search].append(item.text)     return resultdict 


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -