
Am .11.2017, 14:55 Uhr, schrieb Chris Jerdonek <chris.jerdonek@gmail.com>:
It would suffice to be able to specify the starting point for the iterator `root.iter(*tags)` -- in other words to start it midway through. Is there a way to do that that doesn't involve, say, first iterating through the first elements of `root.iter(*tags)`?
Depends on how you define efficiency… You can always use XPath to access specific elements or just `find(fully_qualified_tagname)`. However, if it's a large file you might want to keep memory use as low as possible and use the event-based `iterparse()` approach. lxml adds some comfort to the etree.iterparse function by letting you pass in a list of the tags you're interested in. Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-6226