Thank you - I will try that.

Yep - in memory. No real choice as some attributes and elements that must be
set at the top I don't know until I have written the complete document.

Thanks - dave


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edwin Dankert
Sent: Monday, December 13, 2004 11:14 AM
To: David Thielen
Cc: [EMAIL PROTECTED]
Subject: Re: [dom4j-user] Two suggested improvements for dom4j

You create your document in memory ???

If this is the case, you can use text to
correctly format your text and use different
output formats to change the way the output
is written.

<code>*
Element data = new DefaultElement( "Data");
Element font = new DefaultElement( "Font");
font.add( new DefaultText( "hi there"));

data.add( new DefaultText( "    "));
data.add( font);
data.add( new DefaultText( "    "));

// Normal output.
OutputFormat format = new OutputFormat();
XMLWriter writer = new XMLWriter( System.out, format);
writer.write( data);

// This should give you:
// <Data>    <Font>hi there</Font>    </Data>

// 'Pretty' output
format.setNewLines( true);
format.setIndent( "  ");
writer.write( data);

// This should give you:
// <Data>
//   <Font>hi there</Font>
// </Data>

</code>

The writer should not add or remove information
unless you tell it to.

Regards,
Edwin

*note: code not tested



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to