F.Y.I..

There has been support for Jython in the ElementTree subversion repository since 2005 in the form of a  file named JavaXMLTreeBuilder.py .

Below is a  sample of its explicit use as a parameter with the version 1.2.7 of ElementTree, by passing a TreeBuilder instance to the ElementTree.parse as the default parser. Of course you can set it as the default parser in ElementTree.py by modifying the DefaultParserAPI line to be:

parser_api = default_parser_api = DefaultParserAPI(parser=JavaXMLTreeBuilder())

Regards,

Anthony

----------------------------

89> jython
Jython 2.2.1 on java1.6.0_03
Type "copyright", "credits" or "license" for more information.
>>> from elementtree.ElementTree import ElementTree
>>> from elementtree.JavaXMLTreeBuilder import TreeBuilder
>>> tree = ElementTree()
>>> tree
<elementtree.ElementTree.ElementTree instance 1>
>>> root = tree.parse('nsexample.xml', TreeBuilder())
>>> for each in root:
...  each
...
<Element {http://purl.org/dc/elements/1.1/}Description at 2>
<Element { http://purl.org/dc/elements/1.1/}Title at 3>
<Element {http://fourthought.com/timelog}MinIncrement at 4>
<Element { http://fourthought.com/timelog}InvoiceNumber at 5>
>>>
>>>
>>> from elementtree.ElementTree import dump
>>> dump(tree)
<ns0:ClientInfo xmlns:ns0=" http://fourthought.com/timelog">
  <ns1:Description xmlns:ns1="http://purl.org/dc/elements/1.1/">
    Fourthought, Inc
  </ns1:Description>
  <ns1:Title xmlns:ns1="http://purl.org/dc/elements/1.1/">
    Management Subcontracting
  </ns1:Title>
  <ns0:MinIncrement>0.25</ns0:MinIncrement>
  <ns0:InvoiceNumber>7777</ns0:InvoiceNumber>
</ns0:ClientInfo>
>>>