Don't do element.clear() (make it conditional)
element.clear() removes a parsed element from the tree, basically not allowing it to parse it again.
I would like to request te make this behavior conditional.
You can always extend the lxml handler and add your custom logic, the api is pretty concrete and I don't see changing it any time soon. You are parsing from lxml.etree.Element right? why not copy it and keep it somewhere safe before parsing?
I am reluctant to add this because it will impact everyone for an "edge" case, that people can easily overcome with above suggestions.
You can always extend the lxml handler and add your custom logic, the api is pretty concrete and I don't see changing it any time soon. You are parsing from
lxml.etree.Elementright? why not copy it and keep it somewhere safe before parsing?
I think a deep copy is required, which is again an expensive operation. What I am trying to achieve here is to keep the document available which can be used to query information from. With the current xsData behavior that information is gone after parsing the object once.
I am reluctant to add this because it will impact everyone for an "edge" case, that people can easily overcome with above suggestions.
A 'workaround' would be trivial, and I think that should make it into the documentation / examples. To be honest, I don't see why the clear is a good thing in the first place. Could you elaborate on this too?
It's for saving memory during parsing https://lxml.de/parsing.html#iterparse-and-iterwalk
If you have elements with a long list of children in your XML file and want to save more memory during parsing, you can clean up the preceding siblings of the current element:
Closing for now, I will gladly accept a docs contribution