Set the suppress declaration to true to turn off the xml instruction header.
It should look something like this..
Document document = ...
org.dom4j.io.OutputFormat of = org.dom4j.io.OutputFormat.createCompactFormat();
of.setIndent(true);
of.setNewlines(true);
of.setExpandEmptyElements(false);
of.setOmitEncoding(false);
of.setSuppressDeclaration(true);
of.setEncoding("UTF-8");
of.setTrimText(true);
java.io.ByteArrayOutputStream os = new java.io.ByteArrayOutputStream();
java.io.BufferedOutputStream bos= new java.io.BufferedOutputStream(os);
org.dom4j.io.XMLWriter xmlWriter = new org.dom4j.io.XMLWriter(of);
xmlWriter.setOutputStream(bos);
xmlWriter.write(document);
xmlWriter.close();
String xml = os.toString();
System.out.println("xml=\n"+xml);
Enjoy!
Dave
Frank Sharpless wrote:
How do you write a DOM object to a file without it including the xml "header" information?
In other words, I don't want the following line included at the top of the file:
<?xml version="1.0" encoding="UTF-8"?>
Thanks,
Frank Sharpless
Manager, Application Development
Paperhost.com, Inc.
770.998.9172.611
--
+------------------------------------------------------------+ | David Lucas mailto:[EMAIL PROTECTED] | | Lucas Software Engineering, Inc. (740) 964-6248 Voice | | Unix,Java,C++,CORBA,XML,EJB (614) 668-4020 Mobile | | Middleware,Frameworks (888) 866-4728 Fax/Msg | +------------------------------------------------------------+ | GPS Location: 40.0150 deg Lat, -82.6378 deg Long | | IMHC: "Jesus Christ is the way, the truth, and the life." | | IMHC: "I know where I am; I know where I'm going." <>< | +------------------------------------------------------------+ Notes: PGP Key Block=http://www.lse.com/~ddlucas/pgpblock.txt IMHO="in my humble opinion" IMHC="in my humble conviction" All trademarks above are those of their respective owners. ------------------------------------------------------- This SF.NET email is sponsored by: Geek Gift Procrastinating? Get the perfect geek gift now! Before the Holidays pass you by. T H I N K G E E K . C O M http://www.thinkgeek.com/sf/ _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user