Hi lists, I've just started exploring with ElementTree API with lxml. As I need xpath, original etree is not my favour this time. I'm writing a small module to wrapping up a XBEL file. I do it originally with libxml2 and found that it is too difficult to handle. But when trying to port my beta vesion module to lxml base I can't found any way to do the following stuff.. is it I have overlook anything. Or these functionality isnot explosed by lxml? 1. Setting 'DTD' declaration and XML declaration that is something like the following libxml2 o = libxml2.newDoc("1.0") o.createIntSubset("xbel", XBEL_DTD_SYSTEM_ID, XBEL_DTD_PUBLIC_ID) Is there any way to do the same thing with lxml? 2. Writing an indented version of the XML file that is someting like 'formatDump(file, 1)' in libxml2 3. getting 'sibling' and 'parent' Regards, Zarick Lau
Zarick Lau wrote: [snip]
I'm writing a small module to wrapping up a XBEL file. I do it originally with libxml2 and found that it is too difficult to handle. But when trying to port my beta vesion module to lxml base I can't found any way to do the following stuff.. is it I have overlook anything. Or these functionality isnot explosed by lxml?
Unfortunately any of these functionalities are not supported by lxml yet. That doesn't mean we don't want them supported, eventually, it's just nobody has gotten around to exposing them.. Patches are welcome, of course. :)
1. Setting 'DTD' declaration and XML declaration that is something like the following libxml2 o = libxml2.newDoc("1.0") o.createIntSubset("xbel", XBEL_DTD_SYSTEM_ID, XBEL_DTD_PUBLIC_ID)
Is there any way to do the same thing with lxml?
2. Writing an indented version of the XML file that is someting like 'formatDump(file, 1)' in libxml2
3. getting 'sibling' and 'parent'
I know there's a patch out there for parent and I'm considering it, though it would extend the ElementTree API further, something which I've tried to avoid for core dom-like functionality. I guess next and previous siblings are next, though figuring out what this means is a bit more tricky, as ElementTree's model doesn't have text nodes, while they do exist in the underlying libxml2 tree. Regards, Martijn
participants (2)
-
Martijn Faassen
-
Zarick Lau