Stefan Behnel wrote: > [EMAIL PROTECTED] wrote: > > I have an XML file which contains entries of the form: > > > > <idlist> > > <myID>1</myID> > > <myID>2</myID> > > .... > > <myID>10000</myID> > > </idlist>
Thanks to everybody for the pointers. ElementTree is what I ended up using and my looks like this (based on the ElementTree tutorial code): def extractIds(filename): f = open(filename,'r') context = ET.iterparse(f, events=('start','end')) context = iter(context) even, root = context.next() for event, elem in context: if event == 'end' and elem.tag == 'Id': yield elem.text root.clear() As a result I can do: for id in extractIds(someFileName): do something -- http://mail.python.org/mailman/listinfo/python-list