[xml] How do I get the encoding of an XML document?
- From: "Jean Jordaan" <jean jordaan gmail com>
- To: xml gnome org
- Subject: [xml] How do I get the encoding of an XML document?
- Date: Wed, 3 Jan 2007 11:53:55 +0200
Hi there
I'd like to find the encoding of an XML document, as detected by
libxml2, using the Python bindings. From lxml, I can get it like this:
et
<etree._ElementTree object at 0xb7cc992c>
et.docinfo.encoding
'windows-1252'
According to the lxml API docs, lxml gets this information from libxml2 (see
http://codespeak.net/lxml/api.html#parsers )
How do I get at it without depending on lxml? The only way I've been
able to find is using debugDumpDocumentHead, which just prints to
stdout.
dh = xml.debugDumpDocumentHead(xml)
DOCUMENT
version=1.0
encoding=windows-1252
standalone=true
Regards,
--
jean . .. .... //\\\oo///\\
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]