[lxml-dev] docinfo.doctype doesn't include internal entities?

Sidnei da Silva sidnei at enfoldsystems.com
Sat Apr 18 04:48:09 CEST 2009


Hi there,

I am looking for a way to output internal entities that have been
parsed from the original document when writing out a tree, but
apparently this is not exposed in any attribute.

Here's an example:

{{{
import lxml.etree

document = """<?xml version="1.0"?>
  <!DOCTYPE application [
    <!ENTITY nbsp "\&#160;">
  ]>
  <application>&nbsp;</application>
"""


tree = lxml.etree.fromstring(document)
print tree.getroottree().docinfo.doctype
}}}

I would expect this to output:
{{{
  <!DOCTYPE application [
    <!ENTITY nbsp "\&#160;">
  ]>
}}}

But instead it gives me:

{{{
  <!DOCTYPE application>
}}}

Is it a bug or I'm not looking at the right place?

-- 
Sidnei da Silva


More information about the lxml-dev mailing list