I've finally found the time to release lxml. So here then is
lxml, release 0.5! The very brief lxml FAQ Q: What is lxml? A: It's a Pythonic wrapping for libxml2 and libxslt Q: What does that do? A: It does XML, parsing it, writing it, manipulating it,
searching in it (XPath), transforming it (XSLT), and
validating it (Relax NG), plus more. Q: But doesn't libxml2 already have a Python wrapper? A: Yeah, but it's not pythonic at all. It's huge and difficult to comprehend, it's low level, you can get segfaults and you have to do your own memory management. Q: Why isn't this in the Python package index? A: I forgot my password, and resetting my password doesn't appear
to work correctly. The error already turned out to be reported in the PyPI issue tracker on sourceforge.
(6) Fri Apr 08 2005 20:56 lxml released at last:
- Comments:
Posted by Fredrik at Fri Apr 08 2005 22:15
You rule!
Posted by Fredrik at Fri Apr 08 2005 22:18
This is slightly bad, though: "ElementTree ignores comments when parsing XML, while etree will read them in and treat them as Comment elements."My suggestion is add a flag (or an alternate parser constructor) that controls this; by default, comments should be ignored.Comment and PI support will be added to ElementTree 1.3. It should be trivial to make lxml.etree compatible with the new features; more on this later.
Posted by Martijn Faassen at Fri Apr 08 2005 22:30
Heh, I didn't even recall that incompatibility, I just kept notes as I was going (good thing I did). I can see how this is bad from the compatibility perspective though, so I'll look into creating some option that allows comments to be ignored when you're walking through the tree. Thanks for the note!
Posted by John Mudd at Tue Apr 12 2005 14:36
I looked at the elementTree example:
http://effbot.org/zone/element-index.htmroot = Element("html")
head = SubElement(root, "head")
title = SubElement(head, "title")
title.text = "Page Title"Then I looked at the Hierarchical data objects (HDO) example:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286150model=HierarchicalData()
# model.person is contstruted on the fly:
model.person.surname = "uwe"
model.person.name = "schmitt"
model.number = 1I like how HDO builds the tree "on the fly". Is this available with lxml? If not, is it worth considering?Posted by Martijn Faassen at Tue Apr 12 2005 16:52
It would make sense to look at other Pythonic APIs for XML besides ElementTree, that do something similar to your example, and see whether we can make that work with lxml.There are any number of Pythonic APIs for XML that we may want to consider. There are also many subtleties involved (how does your example know element order, for instance?). The bindery facility in the Amara library is one thing I intend to look at one day.If you want to discuss this further, perhaps you want to take it to the lxml mailing list?
Posted by B Mahoney at Wed Apr 13 2005 08:12
The . notation for an XML hierarchy may seem Pythonic, but I don't understand how it deals with any XML names containing '-' or '.' Should I even wonder about XML namespaces?If your XML may possibly have names such as 'name' or 'value' which are dynamically assigned to Python objects, what are you going to do with your Python XML class supporting this dynamic naming, which might reasonably have a long term claim on appropriately named properties and methods with the same names of 'name' and 'value'
You can avoid namespace collisions, but I can imagine a lot of programmer confusion depending on what names pop up with the XML you are dealt.
