paulb@253 | 1 | #!/usr/bin/env python |
paulb@253 | 2 | # -*- coding: iso-8859-15 -*- |
paulb@253 | 3 | |
paulb@253 | 4 | import libxml2dom |
paulb@253 | 5 | d = libxml2dom.parseString("""<?xml version='1.0' encoding="iso-8859-15"?> |
paulb@253 | 6 | <doc> |
paulb@253 | 7 | <![CDATA[I am the character data champion! ??????]]> |
paulb@253 | 8 | </doc> |
paulb@253 | 9 | """) |
paulb@253 | 10 | d2 = libxml2dom.createDocument("http://www.w3.org/1999/xhtml", "html", |
paulb@253 | 11 | libxml2dom.createDocumentType("html", "-//W3C//DTD XHTML 1.1//EN", "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd")) |
paulb@253 | 12 | doc = d.xpath("doc")[0] |
paulb@253 | 13 | doc2 = d2.importNode(doc, 1) |
paulb@253 | 14 | html = d2.xpath("*")[0] |
paulb@253 | 15 | html.appendChild(doc2) |
paulb@253 | 16 | |
paulb@253 | 17 | print d2.toString("iso-8859-15") |
paulb@253 | 18 | |
paulb@253 | 19 | # vim: tabstop=4 expandtab shiftwidth=4 |