lxml.etree versus ElementTree
=============================

A lot of care has been taken to ensure compatibility between etree and
ElementTree. Nonetheless, besides missing features in lxml.etree, some
differences and incompatibilities exist:

* Importing etree is obviously different; etree uses a lower case
  package name, while ElementTree a combination of upper-case and
  lower case in imports::

  # etree
  from lxml.etree import Element

  # ElementTree
  from elementtree.ElementTree import Element

  When switching over code from ElementTree to etree, and you're using
  the package name prefix 'ElementTree', you can do the following::

  # instead of
  from elementtree import ElementTree
  # use
  from lxml import etree as ElementTree

* ElementTree has a bug when serializing an empty Comment (no text
  argument given) to XML, etree serializes this successfully.

* When trying to set a subelement using __setitem__ that is in fact
  not an Element but some other object, etree raises a TypeError, and
  ElementTree raises an AssertionError.

* ElementTree ignores comments when parsing XML, while etree will read
  them in and treat them as Comment elements.

* Because etree is built on top of libxml2, which is namespace prefix
  aware, etree preserves namespaces declarations and prefixes while
  ElementTree tends to come up with its own prefixes (ns0, ns1,
  etc). When no namespace prefix is given however, etree creates
  ElementTree style prefixes as well.

* etree delivers unicode strings whereas ElementTree often returns
  ascii strings where this is enough.
