[lxml-dev] ElementTree docinfo attribute

David Soulayrol dsoulayrol at free.fr
Mon Aug 25 09:48:24 CEST 2008


Le samedi 23 août 2008 à 13:55 +0200, Stefan Behnel a écrit :
> Hi,
> 
> David Soulayrol wrote:
> > I can read at
> > http://article.gmane.org/gmane.comp.python.lxml.devel/1106/match=docinfo
> > 
> > "a DocInfo object that you can also instantiate on an ElementTree (or
> > Element) by hand."
> > 
> > But I also can read from _ElementTree help : 
> > 
> > "docinfo: Information about the document provided by parser and DTD.
> > This value is only defined for ElementTree objects based on the root
> > node of a parsed document (e.g.  those returned by the parse
> > functions)."
> 
> I just added ", not for trees that were built manually." at the end, that
> should make it clearer.
> 
> 
> > In any case, the docinfo property of ElementTree seems read only. So
> > please tell me, is it possible to fill the docinfo property of an
> > ElementTree by hand, or is it necessary to use the etree parse method ?
> 
> What information would you like to add, and for what purpose?

I have a method which takes a NS map, a root tag and DTD info and should
return a correct document with all these info set. I was wondering if
the only way to do this was to write everything inside a string and then
call the parser with StringIO.


-- 
David.



More information about the lxml-dev mailing list