Provide some way to pass in a pre-built libxml2 tree
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Fix Released
|
Wishlist
|
Unassigned |
Bug Description
Hi,
Reading through the docs/FAQ I see no way to pass a pre-built libxml2 tree to lxml (say via a Py_Capsule).
Background:
In my application, I use a custom C based parser that results in a xmlDocPtr (libxml2 document). I would like to convert this into an lxml tree. However, I could find no API for doing this in lxml.
Ideally, I'd like a python api, something like
from lxml.etree import wrap_libxml2_
root = wrap_libxml2_
Where free function should be a python function that is passed the capsule as an argument and is responsible for freeing the memory in the libxml2 document. If free_function is None, lxml should clone the tree.
I'd be willing to implement this myself if you can give me a few pointers on where to get started in the lxml codebase.
Changed in lxml: | |
milestone: | none → 3.8.0 |
status: | Triaged → Fix Committed |
Changed in lxml: | |
status: | Fix Committed → Fix Released |
On second thoughts, when free_function is None, it should probably default to using xmlFreeDoc() rather than creating a copy.