RE: [xml] correct way to output HTML without the <?xml...


An XML document instance must have an xml declaration otherwise it is not
valid XML.  If you want to have no xml declaration you need to output SGML.
Only SGML documents allow not declaration as the very first line in the
document.  I'm not sure how to get SGML output using libxml2 but .  Your
"-//W3C//DTD HTML 4.01 Transitional//EN" doctype is SGML.  Maybe your
statement about "xml_output_buffer" is wrong.  Is there an
'sgml_output_buffer' in libxml2 that you could use?

I hope that this helps.


-----Original Message-----
From: xml-bounces gnome org [mailto:xml-bounces gnome org] On 
Behalf Of Nic James Ferrier
Sent: Wednesday, 24 May 2006 3:10 AM
To: libxml
Subject: [xml] correct way to output HTML without the <?xml...

I've got a libxml2 DOM with HTML in it (note: it's just an XML DOM
with HTML in it).

I want to output it as well-formed HTML, preferably with the HTML4
transitonal DTD but no xml declaration, eg:

      <link rel="xxx" .../>

I'm not sure of the right way to achieve this.

I tried this:

    htmldoc = libxml2.newDoc("1.0")
    html4_transitional = htmldoc.newDtd("HTML", "-//W3C//DTD 
HTML 4.01 Transitional//EN",
"utf-8", 1)

but that spits out HTML without the DTD or a well-formed DOM.

Outputting with:

   xml_output_buffer.saveFormatFileTo(htmldoc, 'UTF-8', 1)

outputs the XML including the XML declaration, which I don't want
since this is well-formed HTML.

Anybody know the right way to go about this?

xml mailing list, project page
xml gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]