[lxml-dev] ElementTree.write default_namespace argument
Stefan Behnel
stefan_ml at behnel.de
Tue May 12 16:24:48 CEST 2009
Hi,
Richard Lewis wrote:
> I have lxml version 2.1.5, Python 2.5 both installed from Debian
> packages. I'd like to be able to use the default_namespace argument to
> ElementTree's write method.
Yep, that's not supported. It's not easy to add, and it would actually
make more sense to change the prefix in the tree rather than on
serialisation.
> document.write(file(new_filename, 'w'), encoding='utf-8',
> method='html', default_namespace='html')
Note that 'html' is not a valid namespace URI.
> My application is extracting nodes from numerous XHTML documents and
> merging them into one HTML document.
In which case there shouldn't be any namespace at all.
> The bit that's going wrong is
> writing the resultant HTML to a file.
Could you elaborate on the "going wrong" bit? What is the result (of what
kind of operation) and what did you expect instead?
Note that lxml.html has an "xhtml_to_html()" function, maybe that helps
already.
Stefan
More information about the lxml-dev
mailing list