Both Mike and Mattias are both correct. The XML
declaration is exactly that, an XML declaration and it is not a processing
instruction. It may look like a processing instruction though (one of XML's
quirks).
So I take it that you are using document.asXML() or
document.write(Writer) to turn the Document back into into XML text? If so, the
only way to supress the XML declaration is to use the XMLWriter and
OutputFormat(). The XML declaration is not really there, in a dom4j Document. It
is just added by default in the asXML() or write() methods of
Document.
Another option is to just output the root element
and not the document.
Document doc = ...;
String theXML =
doc.getRootElement().asXML();
Note that the above is a bit of a back and would
loose any comments or processing instructions outside of the root element. for
example consider this XML document, however for data-centric XML programs it
could work.
<?xml version="1.0"?>
<?some-pi value="cheese"?>
<!-- a comment --->
<root>
<bar/>
</root>
<!-- another comment -->
<?another-pi value="pizza"?>
|
- [dom4j-user] Processing Instruction problem with removeP... JavaXML Developer
- RE: [dom4j-user] Processing Instruction problem wit... Mike Skells
- RE: [dom4j-user] Processing Instruction problem wit... Mattias Reichel
- RE: [dom4j-user] Processing Instruction problem... JavaXML Developer
- James Strachan