html - How do I take off the XML version tag in the XOM library for Java? -


i'm writing small application in java uses xom output xhtml.

the problem xom places following tag before html:

<?xml version="1.0" encoding="utf-8"?> 

i've read documentation, can't seem find how remove tag. guys.

edit: i'm outputting file using xom's serializer class

follow up: if practice use xml tag before doctype, why don't websites use it? also, why w3c validator give me , error when sees xml tag? here error:

illegal processing instruction target (found xml) 

finally, if put xml tag before doctype, mean don't have specify <meta charset="utf-8" /> in html header?

the tag valid xml , xhtml, , good practice. there should no reason remove it.

just leave there ... or fix whatever is expecting not there.


if don't believe me, take @ excerpt xhtml 1.1 spec.

"example of xhtml 1.1 document

 <?xml version="1.0" encoding="utf-8"?>  <!doctype html public "-//w3c//dtd xhtml 1.1//en"      "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">  <html version="-//w3c//dtd xhtml 1.1//en"        xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"        xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"        xsi:schemalocation="http://www.w3.org/1999/xhtml                       http://www.w3.org/markup/schema/xhtml11.xsd"  >    <head>      <title>virtual library</title>    </head>    <body>      <p>moved <a href="http://example.org/">example.org</a>.</p>    </body>  </html> 

note in example, xml declaration included. xml declaration 1 above not required in xml documents. xhtml document authors should use xml declarations in documents. xhtml document authors must use xml declaration when character encoding of document other default utf-8 or utf-16 , no encoding specified higher-level protocol."


by way, w3c validation service says ok ... if there whitespace before <?xml ...?> tag complains.


Comments