I just found the answer... setTrimText(false)


        OutputFormat format = OutputFormat.createPrettyPrint();
        format.setIndent("    ");
        format.setTrimText(false);
        XMLWriter writer = new XMLWriter(theFileWriter, format);

Thanks!

Begin forwarded message:

From: Philip Weaver <[EMAIL PROTECTED]>
Date: Sun Aug 10, 2003  9:34:00 AM US/Central
To: [EMAIL PROTECTED]
Subject: Using PrettyPrint & Retaining New Line Chars


Without success, I've been trying to get XMLWriter use pretty print but also preserve new line chars; e.g. \n. I discovered that when I do not use a custom OutputFormat, the document DOES retain the new line chars.


I've tried the following idea but it still will not preserve the new line chars:

        OutputFormat format = OutputFormat.createPrettyPrint();
        format.setIndent("    ");
        format.setLineSeparator("\n");
        format.setNewlines(true);
        XMLWriter writer = new XMLWriter(theFileWriter, format);

How can I use pretty print and still have it preserve new line chars? Or should I just go about encoding the return chars myself before saving the XML document?

Thanks,
Philip Weaver




------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to