Does findall() return elements in document order?
Hello, I have a simple question: Does the findall() method of lxml return elements in document order? So far, I find empirically that it does, and I have not seen an exception to this rule. But the documentation does not mention anything about the ordering of the elements being returned. Does the implementation still guarantee, that elements are returned in document order? Thanks for your help, Eero
Hi, even if not documented for lxml, findall will follow the ElementTree API: Finds all matching subelements, by tag name or path. Returns a list containing all matching elements in document order. namespaces is an optional mapping from namespace prefix to full name. Pass '' as prefix to move all unprefixed tag names in the expression into the given namespace. https://docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.Eleme... (effbot.org seems to be on hiatus). jens
On 12. 10. 2021, at 10:49, Eero Holmström <eero.holmstrom@gmail.com> wrote:
Hello,
I have a simple question: Does the findall() method of lxml return elements in document order?
So far, I find empirically that it does, and I have not seen an exception to this rule. But the documentation does not mention anything about the ordering of the elements being returned. Does the implementation still guarantee, that elements are returned in document order?
Thanks for your help, Eero _______________________________________________ lxml - The Python XML Toolkit mailing list -- lxml@python.org To unsubscribe send an email to lxml-leave@python.org https://mail.python.org/mailman3/lists/lxml.python.org/ Member address: jq@qdevelop.de
participants (2)
-
Eero Holmström
-
Jens Quade