Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dom4j XML declaration in document

I need to remove XML declaration from dom4j document type

I am creating document by

doc = (Document) DocumentHelper.parseText(someXMLstringWithoutXMLDeclaration);

String parsed to Document doc by DocumenHelper contains no XML declaration (it comes from XML => XSL => XML transformation) I think that DocumentHelper is adding declaration to a document body ?

Is there any way to remove XML declaration from the body of

doc
like image 677
Marcin Wasiluk Avatar asked Sep 14 '26 22:09

Marcin Wasiluk


1 Answers

The simpler solution I choose is

doc.getRootElement().asXML();
like image 112
Jerry Meng Avatar answered Sep 16 '26 11:09

Jerry Meng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!